Vim Learning Summary

Source: Internet
Author: User

Vim ~/.VIMRC

Vim student.cc

First of all. The Mac system already has Vim installed by default. Open terminal, input vim, enter.

You can see, for example, the following interface, which means that Vim is already installed. Enter ": Q" in vim


On the terminal. The interface is simple, assuming you need a more complex interface and many other features of vim, you need to download the client installation. There are now two version numbers on the Mac Vimclient:
1, Macvim. Using the cocoa GUI, this is the version number that is also very active on the Mac, and the version number most people use on the Mac. : http://code.google.com/p/macvim/
2, use the version number of carbon GUI, but this version number is basically no longer updated at the moment. : http://sourceforge.net/projects/macosxvim/files/

This article mainly introduces Macvim,macvim support multi-form label editing and new features such as Fullscreen.

Download the corresponding Macvim compression package, unzip the MacVim.app into the/applications folder. Start Macvim, enter ": H Mvim" and follow the prompts to copy the Mvim script file to the "/usr/local/bin" folder. Open the terminal, enter the command "cd/usr/local" and "sudo mkdir bin", and finally enter "sudo cp-f/users/ericli/software/macvim-snapshot-66/mvim/usr/local/ Bin/", so that the terminal can enter the command" Mvim "to start the Macvim at high speed.

Suppose you do not want to put MacVim.app into the/applications folder, just need to set the VIM_APP_DIR variable in the terminal to the folder you want to place MacVim.app and import into the $home/.bash_profile can be, For example: Export vim_app_dir= $HOME/software/macvim-snapshot-66/.

In Macvim, enter ": H Macvim" To view the documentation for the use of Macvim help.


Today Macvime's interface is still very humble, and here's how to configure Macvim simply:

1. Create a ~/.BASHRC file

          Type "CD $HOME" and "touch. BASHRC" in the terminal, which is a successful creation. Open the file. Enter "Alias Vim=mvim". and save the alias variable. Then type "source. BASHRC" in the terminal to make the. bashrc file effective. In this way, both vim and Mvim in the terminal are able to start the MacVim.app.

        here to explain the role of the next few files,/ETC/BASHRC,/etc/ Profile is the system global settings environment variable, for all users, ~/.BASHRC, ~/.bash_profile, ~/.bash_login, ~/.profile is the user folder under the private variable settings. When entering the system to execute a bash shell process, the read environment setting steps such as the following: 1, read the global Settings environment variable/etc/profile, and then according to its contents read/ETC/PROFILE.D,/ETC/BASHRC and other settings. Note that/etc/profile is only read once when the bash shell is executed for the first time, and/ETC/BASHRC is read every time the bash shell executes, 2, and then reads ~/.bash_profile, ~/.bash_, under the current User folder. Login or ~/.profile a local variable setting in one of the three files, and only read the first time the bash shell is executed, only read ~/.bash_profile fails to read ~/.bash_login. It is assumed that the front two file read failed to read ~/.profile. 3, finally according to the content of ~/.bash_profile read the current User folder in the ~/.BASHRC file in the Local settings environment variables, ~/.BASHRC file in each open new bash shell read once.

Sum up. /ETC/BASHRC,/etc/profile, ~/.BASHRC, ~/.bash_profile, ~/.bash_login, and ~/.profile all have environment variable settings. And/etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile can set the path, environment variables, and so on, only can log in when run once;/ETC/BASHRC, ~/.BASHRC save path, command aliases and so on, each time you open a new bash shell, it will run once. Usually the former/etc/profile, ~/.bash_profile call the latter/ETC/BASHRC, ~/.BASHRC. More specific information can be in the link: http://blog.chinaunix.net/uid-24591881-id-2124780.html.

2. Configuring ~/.VIMRC and ~/.GVIMRC

First, enter ": Version" in the Macvim editor to see, for example, a message:


From the ability to see some macvim configuration information:

The path to the $VIM system variable is: "/applications/macvim.app/contents/resources/vim"

Path to the Macvim system profile VIMRC: "$VIM/VIMRC"

Path to user profile VIMRC: "$HOME/.VIMRC"

The path of the user initialization profile for the Macvim editor: "$HOME/.EXRC" (default does not exist.) If you need to use it, enter "Touch $HOME/.VIMRC" in the terminal to create)

Path to the Macvim system profile GVIMRC: "$VIM/GVIMRC"

Path to user profile GVIMRC: "$HOME/.GVIMRC"

Path to the Macvim menu file: "$VIMRUNTIME/menu.vim"

In addition, the $HOME is the path to the current user folder. $VIMRUNTIME path is "/applications/macvim.app/contents/resources/vim". The ability to enter ": Echo $VIMRUNTIME" in Macvim to see the path to these system variables.

Second, the contents of the copy standard from the system files Vimrc_example.vim and Gvimrc_example.vim are saved to the user's profile ~/.VIMRC and ~/.GVIMRC. Enter for example the following command in Macvim:

[HTML]View Plaincopy
  1. : E $VIMRUNTIME/vimrc_example.vim
  2. : SaveAs ~/.VIMRC
  3. : E $VIMRUNTIME/gvimrc_example.vim
  4. : SaveAs ~/.GVIMRC

3. Add Plugin

There are usually two ways to add plugins, such as the following:

One: Copy the Plugin_name.vim plugin into your personal plugin folder ~/.vim/plugin/. Copy Plugin_help.txt to your personal Documents folder ~/.vim/doc/, if there is a VIM support file syntax The plugin is placed under the ~/.vim/syntax/folder. Assume that the above folder does not exist to the terminal input such as the following command created:

[HTML]View Plaincopy
[HTML]View Plaincopy
[HTML]View Plaincopy
  1. CD $HOME
  2. mkdir. Vim
  3. mkdir. Vim/plugin
  4. mkdir. Vim/doc
  5. mkdir. Vim/syntax
      For example, copy Matchit.txt to ~/.vim/doc/, copy Matchit.vim to folder ~/.vim/plugin/.

Second. At the end of your VIMRC configuration file, add a line command:

[HTML]View Plain

Vim Learning Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.