vim配置文件
:vimrc
普通模式下常用命令
:s/foo/bar/g change each 'foo' to 'bar' in the current line
:%s /foo/bar/g change each 'foo' to 'bar' in all lines
:123[Enter] takes you to line 123 in the file
123[Enter] takes you 123 lines down from your present position
u undo last change
ctrl-R Redo changes which were undo
gg Jump to the start of the file
G Jump to the end of the file
dG Delete from the current line to the end of the line
o insert newline after the current line
O insert newline before the current line
x 删除光标所在字符
rc 将当前字符替换成c
:set expandtab insert space characters whenever tab key is pressed
:set tabstep=4 insert 4 space for a tab
/word 查找单词word
Find a whole word
\< represents the begining of a word
\> represents the end of a word
to find only the whole word "i" use pattern:
\<i\>
关于:map
:map j gg j will be mapped to gg
:map Q j Q will be mapped to gg
:noremap w j W will be mapped to j
:map recursive, works in all mode
:noremap non-recursive, works in all mode
:nmap works in normal mode
:nnoremap works in normal mode
例:普通模式插入空格
:nnoremap <space> i<space><ESC>
复制和粘贴
Position the cursor where you want to begin cutting
Press v( or upper v if you want to cut with whole lines)
Move the cursor to the end of what you want to cut
Press y to copy or d to cut
Move to where you would like to paste
Press P to paste before cursor, or p to paste after