vim not a layout program, it is not as WPS MS Word or other attributes may be organized fonts, formatting, paragraphs, etc., it is only a text editor
vim is a full-screen text editor that no menu, only the command
1. Vim editor mode
- 1) command line mode
- 2) Input mode, edit mode
- 3) line mode
- 4) Replace Mode
Command line mode
Save ZZ save and exit cursor: move the cursor hjkl lower left and right cursor to move to the beginning of the home to move to the end of the end move the cursor to the end of the G cursor to the beginning gg cursor one word w paste Copy: Copy copies n row line yy nyy paste p delete: delete x delete character backward forward X delete to delete a row dd ndd delete a word dw undo: undo u step up repeat the last operation. Find: Find / string define \ escape character Find "/ bin / bash "/ \ / bin \ / bash delete and modify the" edit "refers to add text, modify and delete, even including text block move, copy, and so on. In vim it is generally believed that input and editing are two concepts. Editing is performed in command mode, the command to move the cursor to the first use to locate the place to be edited, and then use the appropriate editing command; input is performed in the insertion mode. In the commonly used editing commands in command mode: the X-delete character under the cursor. dd Delete cursor line. r modify the character under the cursor, r is the character to be corrected. R into the replacement state, the entered text will overwrite the original data. s Delete character under the cursor, and enters input mode. S Delete cursor line and enter input mode. cc modify the entire line of text. u undo the last operation. Repeat the last operation.
3. Edit mode
Input mode in the input mode, the bottom left of the screen INSERT appears. In the input mode, the user can enter the content of the text in Insert mode can also delete characters, and the standard of vim editor can not delete a character in edit mode, only insert characters in the command line mode to enter the input mode a cursor from starting position behind the input data, the data after the cursor moves rearwardly with increasing information. A start typing the information from the rearmost position the cursor line. Insert (INSERT) I inserted starting from the front of the cursor position data, cursor data with the new data after the backward movement. I began to insert data from before the first non-blank character cursor line. Start (Open) O a new row at the cursor line and the input mode. O new row above the cursor line and the input mode. How to exit the input mode esc
4. The line mode
Line mode just enter the command in command mode ":" to enter the last line mode. In line mode, you can save the file and exit vim, find and replace operations. : When simultaneously edit multiple files for the same time can only display a file, so the file opened VI switching may be used to switch the N or n open files : n shifts to the next file : a file on a switching N and: q :! q force-quit without saving : W : WQ replace : s / old / new old string only replace the first line where the cursor : s / old / new / g to replace Bank (cursor) all old string of new string g global n represents a line number :% s / old / new / g herein will replace the old string of all new string : 1,2s / Old / new new / replacement G 1-2 rows of old string new string :., 2s / old / new / g cursor representative of the current row to the second row line. : 2, $ S / Old / new new / replacement G 2 to the last line of the old string String new new : NU displaying rows SET No : the SET nonu :! the command execute a command in vim editor (not allowed to exit the current editor, can execute commands in the editor, similar to exit the editor execute command) Find / string the string to the line cursor is located. ? string to move the cursor to the nearest line containing a string strings : n Position the cursor to the n-th row of the file. Save the document can be used: n, mw filename command text to n-th row of the m-th row stored in the specified file filename.
5. Replace Mode
Command line press R to enter the alternative mode exit esc
6. Related Documents
~ / .viminfo vim history edit documents ~ / .vimrc vim personalized document set custom header comments ~ / .vimrc
autocmd BufNewFile *.py,*.sh,*.c exec ":call SetTitle()" func SetTitle() if &filetype == 'python' call setline(1,"\#!/usr/bin/env python") call append(line("."),"\#enconding=utf-8") call append(line(".")+1, "\#Author: Bai Shuming") call append(line(".")+2, "\#Created Time: ".strftime("%Y/%m/%d %H:%M")) call append(line(".")+3, "") elseif &filetype == 'sh' call setline(1,"\#!/usr/bin/env bash") call append(line("."),"\#enconding=utf-8") call append(line(".")+1, "\#Author: Bai Shuming") call append(line(".")+2, "\#Created Time: ".strftime("%Y/%m/%d %H:%M")) call append(line(".")+3, "") elseif &filetype == 'c' call setline(1,"#include ") call append(line("."), "") endif endfunc