星期六, 三月 01, 2008

[tools]my vim cheat sheet

. - repeat last command
O - open blank line above the current line
I - insert at the beginning of the line
A - append at the end of the line
:w - write(save)
:bd - close current buffer
:buffers - show all buffers
:ls - show all buffers
:bn - go to the next buffer
:bp - go to the previous buffer
:edit - edit another file
:sp filename - Open a file in a new buffer and split window
C-w c - close current window
C-w w - change to the next split window
u - undo
C-r - redo
v - visual mode
y - yank,copy
p - paste
yy - yank a line
2yy - yank 2 lines
dd - delete current line

语法提示与自动补齐
★ <C-N><C-P> 插入模式下的单词自动完成
★ <C-X><C-L> 行自动完成(超级有用)

--------------- moving around ---------------------
C-e - scroll down 1 line
C-d - scroll down 1 screen
C-y - scroll up 1 line
C-u - scroll up 1 screen
C-f/b - scroll forward/backward
zz - see the context of the line with cursor.
L - move the cursor to Low
M - move the cursor to Middle
H - move the cursor to High
* - search the word under the cursor
/searchword\c - search the word and ignorecase
:%s/foo/bar/g - replace 'foo' with 'bar' without ask
:%s/foo/bar/gc - replace 'foo' with 'bar' and ask you for grant every time
C-o - jump to last old position
C-i - jump to next new position (on the keyboard, "i" is next to "o")
m{a-zA-Z}, then ' or `{a-zA-Z} - m{a-zA-Z} to mark current position, ' or `{a-zA-Z} move to the marked position.
'' or `` - To the position before latest jump.
(            [count] sentences backward.  |exclusive| motion.
)            [count] sentences forward.  |exclusive| motion.
{            [count] paragraphs backward.  |exclusive| motion.
}            [count] paragraphs forward.  |exclusive| motion.

--------------- programming tips ---------------------
:!ctags *.c - use ctags
== - indent the current line
v(select), == - indent the selected block

--------------- select things quickly---------------------
The objects that can be used are:
    aw    a word (with white space)            |v_aw|
    iw    inner word                    |v_iw|
    aW    a WORD (with white space)            |v_aW|
    iW    inner WORD                    |v_iW|
    as    a sentence (with white space)            |v_as|
    is    inner sentence                    |v_is|
    ap    a paragraph (with white space)            |v_ap|
    ip    inner paragraph                    |v_ip|
    ab    a () block (with parenthesis)            |v_ab|
    ib    inner () block                    |v_ib|
    aB    a {} block (with braces)            |v_aB|
    iB    inner {} block                    |v_iB|
    a<    a <> block (with <>)                |v_a<|
    i<    inner <> block                    |v_i<|
    a[    a [] block (with [])                |v_a[|
    i[    inner [] block                    |v_i[|

--------------- modify quickly---------------------
gi - go to Insert mode where you last left it last time
ci" - change text inside quotes
ci' - change text inside quotes

--------------- vim configure file: .vimrc ---------------------
set number

set fileencoding=gb2312
set fileencodings=utf-8,gb2312,utf-16,big5

set nobackup
set nowritebackup
" set ignorecase "ignore case sensitive

--------------- tips on shell ---------------------
Shift + Insert: insert into shell

--------------- RESOURCES ---------------------
Bram Moolenaar
http://www.moolenaar.net/

七个高效的编辑文本的习惯
http://blog.csdn.net/tangl_99/archive/2007/06/03/1636397.aspx

Seven habits of effective text editing
Bram Moolenaar
http://www.moolenaar.net/habits.html

books: Hacking Vim
https://groups.google.com/group/oss_gucas_linux_newbies/files

vim for php grogrammers


--
 ,           ,
/             \
((__-^^-,-^^-__))
`-_---' `---_-'
 `--|o` 'o|--'
    \  `  /
     ): :(
     :o_o:
      "-"

没有评论: