in linux next, vim is one of the most common editor on many linux distributions comes. I was CentOS 6.3.
Vimbasically divided into three modes, namely, the general pattern, edit mode and command line mode, the role of these three models were summarized as follows:
- Normal mode: the default mode. Vim opens directly into the general pattern, in this mode, the operation can be performed are: move the cursor, copy, paste, delete.
- Edit Mode: Edit the file contents will appear in the lower left of the interface INSERT message.
- command line mode: find, read, preserve, replace characters, display line numbers, leaving vim, etc. operations.
one: Vim under the common command:
j down k up l h left to right
: w (lowercase) to save the file
: wq (lowercase) to save and exit vim
: w filename Save the file name for the file name name
: ZZ (uppercase) Save the file and exit, the equivalent of: wq
: wq! (lowercase) owner of the file read-only file saved to force, if not for the file owner This operation can not be successfully
: q! exit without saving the file
copy (yank)
yy or Y ; copying the entire line where the cursor
y ^ Copy to cursor column header, not including the cursor position character
y $ ; copied to the cursor trekking tail, including cursor position character
yw ; copy a word, the cursor must be in the word's first
yG copied to the end of the file
y1G Copy to File First
nyy Copy the beginning of the line where the cursor n lines
paste
p (lowercase) pasted to the cursor after
P (uppercase) pasted to the cursor before
delete
x (lowercase) to delete a character before the cursor
X (uppercase) deleted after the cursor one character
dd (lowercase) cursor to delete the entire line
dw (lowercase) to delete a word at the cursor
dG ; to delete the entire line where the cursor to the end of file
dgg cursor to delete the entire line to the file first
D (uppercase) to delete end of the line that contains the character at the cursor
d0 Delete to beginning of the line, does not contain the character at the cursor
: n1, n2d edit mode, delete the line n1-n2
withdrawal
u ( lowercase) before saving unlimited withdrawal (about 500 times)
ctrl + r redo redo
Find
/ string is equivalent to find, from the cursor down to start at the beginning of the search string string
/ Find mode, press n (lowercase) Find Next, press N (uppercase) Find previous
? string from the cursor to start looking up at the beginning of the character from the string
? Find mode, press n (lowercase) Find the previous one, press N (uppercase) Find Next
: set nu (mber) Show Line Numbers
: n Move to the specified line n
multi-window function:
: r file reads file content, and inserted in the current line after
: new new column blank window
: split the current file in two columns show
block selection : ctrl + v
two: Vim environment settings
in the directory / etc / below, there is a file called vimrc file, which is the system of public of vim configuration files are valid for all users. And in each user's home directory, you can build your own private configuration file is named: ". Vimrc"
open. vimrc, add the following statement to make syntax highlighting: syntax on
set auto indent : the value of each line with the previous line indent equal; using noautoindent unset:
set autoindent
set using C / C + + language, auto-indent mode: set cindent
filetype plugin on is the use of plug-ins statement
three: c-support.vim plugin
recommend c-support.vim this plug-in can be used to compile c / c + +, very good, oh! ~
c-support.vim Download
http://www.vim.org/scripts/script.php?script_id=213
installation is very simple
Copy the zip archive cvim.zip to $ HOME / .vim / (Linux / Unix) or $ HOME / vimfiles (Windows) and run unzip cvim.zip
installed in $ HOME / .vim /
can use the command $ HOME:
cd ~ /. vim
unzip cvim.zip
in / etc / vim / vimrc add filetype plugin on to use this plug-in.
its hotkey Description:
http://lug.fh-swf.de/vim/vim-c / c-hotkeys.pdf
\ if inserted into the general function
\ im into the main function
\ cfu insert function header, which function description
\ cfr insert a frame comment, can be used to write Variable Description
\ rc Save and compile
\ rr run
\ nr in ~ / .vim / c-support / codesnippets write some precompiled code or code block, through the use of this command
没有评论:
发表评论