Vim provides a variety of configuration functions in a simple way. The main configuration system consists of a file and a folder. On an OS X/Linux/Unix machine installed with vim, go to the user's home directory and find the. vimrc file and. Vim folder. This is all the configurations of vim.
(1) vimrc Introduction
The. vimrc file in the user directory is the main configuration file of VIM for the current user. This file is not necessary. If it is not available, create it. The file is located in the current user's home directory. You can use ~ /. Vimrc is found. When Vim is started, every command in the file is automatically run.
Pass. in vimrc, We can customize the configurations for VIM, including usage, display style, writing functions, and running plug-ins ,. all commands in vimrc can be dynamically run in the vim running mode similar to: comm ARGs [= args1], which takes effect immediately.
The following is a. vimrc sample script, which contains some common configurations. The comments below are a brief description.
The comments of vimrc are represented by double quotation marks ("). The braces in the example only represent the functional area. They are part of the comments and have no other meanings.
. Vimrc has rich configurations and can define various macros, functions, ins and ing. I have seen more than 1000 rows of. vimrc configuration at the longest time. The example here is relatively simple and suitable for entry-level users.
- SYN on "syntax support
-
- "Common conf {general configuration
- Set ai "auto indent
- Set BS = 2 "delete with the return key in insert mode
- Set showmatch "code matching
- Set laststatus = 2 "always displays status rows
- Set expandtab "is used in combination with the following three configurations to set the number of tabs and indentation spaces.
- Set shiftwidth = 4
- Set tabstop = 4
- Set cursorline "underline the row where the cursor is located
- Set number "display row number
- The Set autoread file has been modified outside vim and is automatically re-read.
-
- Case Insensitive for set ignorecase Retrieval
- Set fileencodings = uft-8, GBK "open a file with UTF-8 or GBK
- Set HLS "highlight matching items during retrieval
- Set helplang = cn "helps set the system to Chinese
- Set foldmethod = Syntax "code folding
- "}}
-
- "Conf for tabs: tab configuration. use ctrl H/L to switch labels.
- Let mapleader = ','
- Nnoremap <c-l> GT
- Nnoremap <c-h> GT
- Nnoremap <leader> T: tabe <CR>
-
- "Conf for plugins {plug-in-related configuration
- "Status bar configuration
- "Powerline {
- Set guifont = powerlinesymbols \ for \ Powerline
- Set nocompatible
- Set t_co= 256
- Let G: powerline_symbols = 'fancy'
- "}
- "Pathogen is a plug-in used by VIM to manage plug-ins.
- "Pathogen {
- Call pathogen # infect ()
- "}
-
- "}}
(2). Vim folder
. Vim is the main configuration folder of VIM. It is located in the main directory of the current user. You can use CD ~ /. Vim. This folder is generally used to place plug-ins and related help documents. Common directory structures include:
- Doc // help document directory
- Autoload // directory of the plug-in automatically loaded when Vim is started
- Plugin // plug-in Directory, which is usually called out through commands When Vim is used
Of course, if you have installed enough plug-ins, there will be a wide variety of plug-ins in this directory, and folders such as syntax, snippets, and indent will pop up. Files contained by a plug-in are often distributed in Multiple folders, which is difficult to manage. We will introduce a plug-in for managing plug-ins later, so that the directory is clean, tidy, and easy to manage, the plug-in name isPathogen!
Enter the command: Help in VIM To Go To The Help page. The help page is in English by default. If you like to read Chinese, you can install the Help content in Chinese in the following ways:
Download the compressed Chinese help file package
Decompress the file and copy the file in the doc directory ~ /. Vim/doc
Confirm that set helplang = Cn is set in. vimrc.
Enter the command: Help to enter the Chinese help