Document directory
- Configuration
- The most useful commands
- Useful plug-ins
- Configure Python
Technorati label: vim
I made a note by collecting the contents of the online hosts.
Most common configuration
Set nocompatible "allows vim to avoid some vulnerabilities and restrictions of the original vi.
Set autoindent "uses the indent of your current row to set the indent of your next row
Set smartindent "automatically predicts the indentation of the next row based on the indentation of the current row
"Use 4 tabs for text indent (automatic or manual indent adjustment)
Set tabstop = 4
Set shiftwidth = 4
Set expandtab automatically expands the input TAB into spaces. Enter a TAB after enabling. Ctrl-V <TAB> is required.
Set softtabstop = 4 "facilitates the use of the backspace key after et is enabled, and X spaces are deleted each time
Set nobackup "Cancel backup file
Set showmatch "the cursor quickly locates matching parentheses
Set guioptions-= T "Remove tool bar
Set guioptions-= m "Remove the menu bar
Set vb t_vb = "block the beep sound when an invalid command is encountered, and replace it with a rapid flash
Set rcursor "ensures that each window is packed with A status bar showing the current cursor position
Set nohls "by default, the searched content is highlighted. This command closes the highlighted search content
Set incsearch "when a character is entered, the cursor is quickly located at the corresponding position
The most useful commands
. |
Enter '.' (a period) to repeat the previous command. |
K |
Enter the command explanation page of the string under the current cursor (for example, if you place the cursor on sleep, press K to see the command explanation page of sleep) |
% |
Position the cursor in braces, braces..., and press ENTER % to place the light on the braces or the other half of the brackets. |
CTRL-V |
Block operations, such as adding a comment to each line #: 1. Press Ctrl + V (Ctrl + Q in windows) to enter the block Operation Mode of VIM. 2. Use the j and k keys to move up and down. To select these three rows, make sure that the first column of each row is included in the selected block. 3. Type I (capital I), that is, insert at the beginning of the row. Enter the Python annotator '#'. 4. Press ESC. |
: %! Xxd |
View the hexadecimal encoding of the file and return the text status: %! Xxd-r |
|
|
|
|
: Help options |
View All VIM options |
Useful plug-ins
NERD Commenter |
Help you block comments and reverse comments code |
SnipMate |
Implement code snippets. for example, if you enter for <tab> in the c file, the code snippets required for the entire for loop are automatically entered. In order not to compete with pydiction with the <tab> key, change plugin/snipMate. vim so that snipMate can be ctrl + j: Ino <silent> <c-j> <c-r> = TriggerSnippet () <cr> "Ino <silent> <tab> <c-r> = TriggerSnippet () <cr> Snor <silent> <c-j> <esc> I <right> <c-r> = TriggerSnippet () <cr> "Snor <silent> <tab> <esc> I <right> <c-r> = TriggerSnippet () <cr> |
Snippetsemu |
Implement code snippets, just like snipMate |
Configure Python
autocmd FileType python setlocal et sta sw=4 sts=4
"Replace TAB with four spaces
Code folding
Python_fold
Command: Expand zo, fold zc, expand zn, and fold zN
Code Completion (pydiction)
- Copy the python_pydiction.vim file to C: \ Program Files \ Vim \ vimfiles \ ftplugin or ~ /. Vim/after/ftplugin/
- Copy the pydiction. py and complete-dict Files to C: \ Program Files \ Vim \ vimfiles \ ftplugin \ pydiction or ~ /. Vim/after/ftplugin/pydiction (of course, you can put it anywhere. You just need to pair the location in the next vimrc file.
- Edit the vimrc File
Filetype plugin on
Let g: pydiction_location = 'C: \ Program Files \ Vim \ vimfiles \ ftplugin \ pydiction \ complete-dict'
<Tab> key-to-Call Option
After the Option List menu is displayed, you can select the option from the "tab" drop-down menu, shift + tab reverse selection (up and down arrows are also available)
If you are not satisfied, click another key)
Code Completion (pysmell)
This stuff is similar to pydiction. You just need to select one. The general difference is:
- Convenient buttons without pydiction
- It is a good idea to store dictionary information in the project directory without affecting the overall situation.
Easy_install pysmell
Copy pysmell. vim ~ /. Vim/plugins
Edit vimrc:
Autocmd FileType python setlocal omnifunc = pysmell # Complete
Imap <F4> <C-X> <C-O> "change the default Ctrl-X + O to F4
To the Python directory
Pysmell.-x site-package test-o PYSMELLTAGES. pythonlib;
Pysmell site-package/django-o PYSMELLTAGES. django
Under the project directory
Pysmell.-o PYSMELLTAGS
You can use the Vim auto-completion function. Press the following button:
F4 outgoing call waiting window
Ctrl-N select down
Ctrl-P select up
Code check
Pyflakes-vim is easy to install:
1. Make sure your vimrc has "filetype plugin indent on" so that pyflake-vim's ftplugin files are loaded automatically when you open a Python buffer.
2. Drop extracted files in ~ /. Vim/ftplugin/python.
The problematic code contains a broken wave number. When the cursor moves over, you can see the error message in the status bar.
Ctag and taglist
Copy beibeictags.exe to the directory where the vim executable file is located. Make sure that the directory is in the system path.
Configure taglist in vimrc
Let Tlist_Ctags_Cmd = "ctags.exe"
Map <F2>: Tlist <CR>
F2 shortcut to open or close the browser window
Ctrl-two w switches in the Tag window and source code window
Lazy Method
The above configuration is very troublesome. There is a lazy way to fix all the above plug-ins and configurations:
- Next install gvim72
- Download the compressed package vim.rar (for windows) and decompress it to overwrite your vim installation directory.
Note:
- The vim and gvim files used in this package are compiled to support Python2.5. If you have installed 2.6, download the corresponding vim and gvim files here.
- Install pysmell In the python Environment
Summarize the shortcut keys:
Pydiction |
In insert and edit mode, press <tab> |
Select tab downward, shift + tab reverse selection (up and down arrows are also available) |
Pysemll |
In insert and edit mode, press F4. |
Ctrl-N select down; Ctrl-P select up |
Taglist |
F2 open and close the browsing window |
Ctrl-two w switches in the Tag window and source code window In the browser window, select the upper and lower keys through j and k, and press enter to jump the source code window to the corresponding section, such as the function |