1、bn goto next bufferbp goto previous bufferwn save file and move to next (super)wp save file and move to previousbd remove file from buffer list (super)bun Buffer unload (remove window but not from list)badd file.c file from buffer listb 3 go to buffer 3b main go to buffer with main in name eg main.c
2、 (ultra)sav php.html Save current file as php.html and move to php.htmlsav! %.bak Save Current file to alternative extension (old way) %:r.cfm Save Current file to alternative extensionsav %:s/fred/joe/ do a substitute on file names/fred/joe/:r.bak2 do a substitute on file name & ext.mv % %:r.bak re
3、name current file (DOS use Rename or DEL)e! return to unmodified filew c:/aaa/% save file elsewheree # edit alternative file (also cntrl-)rew return to beginning of edited files list (:args)brew buffer rewindsp fred.txt open fred.txt into a splitsball,:sb Split all buffers (super)scrollbind in each
4、split windowmap lse # : Pressing F5 lists all buffer, just type numberset hidden Allows to change buffer w/o saving current buffer Quick jumping between splitsmap C-Wjk Recording (BEST TIP of ALL)qq # record to qyour complex series of commandsq # end recordingq to execute to Repeat5 to Repeat 5 time
5、s editing a register/recordingqpdisplay contents of register q (normal mode)display contents of register q (insert mode) you can now see recording contents, edit as requiredqddput changed contacts back into qqexecute recording/register q Operating a Recording on a Visual BLOCK1) define recording/reg
6、isterqq:s/ to/ from/gMq2) Define Visual BLOCKV3) hit : and the following appears,4)Complete as followsnorm qcombining a recording with a map (to end up in command mode)nnoremap q:w!barbd Visual is the newest and usually the most intuitive editing mode Visual basicsv enter visual modeV visual mode wh
7、ole lineC-V enter VISUAL BLOCK modegv reselect last visual area (ultra)o navigate visual area*y yank visual area into paste bufferV% visualise what you matchVJ Join Visual block (great)VgJ Join Visual block w/o adding spaces Delete first 2 characters of 10 successive lines010j2ld how to copy a set o
8、f columns using VISUAL BLOCK visual block (AKA columnwise selection) (NOT BY ordinary v command) then select column(s) with motion commands (win32 then c,d,y,r etc how to overwrite a visual-block of text with another such blockPick the first block: ctrl-v move ayPick the second block: ctrl-v move c
9、ctrl-o aP _vimrc essentialsset incsearch : jumps to search word as you type (annoying but excellent)set wildignore=*.o,*.obj,*.bak,*.exe : tab complete now ignores theseset shiftwidth=3 for shift/tabbingset vb t_vb=. set silent (no beep)set browsedir=buffer Maki GUI File Open use current directory l
10、aunching Win IEnmap ,f :updatesilent !start c:progra1intern1iexplore.exe file:/%:pnmap ,i : !progra1intern1iexplore.exe FTPing from VIMcmap ,rNread ftp:/209.51.134.122/public_html/index.htmlcmap ,wNwrite ftp:gvim ftp:/ # uses netrw.vim appending to registers (use CAPITAL) yank 5 lines into a then ad
11、d a further 5a5yy10jA5yyI show lines matching word under cursor (super) Conventional Shifting/Indentingb visual shifting (builtin-repeat)vnoremap Block shifting (magic)ia also% and out.txt redirect to a file Working with Paste buffer*yy yank to paste*p insert from paste buffer yank to paste buffer (
12、ex mode)by* Yank range into paste%y* Yank whole buffer into paste.y* Yank Current line to paster filter non-printable characters from the paste buffer useful when pasting from some gui applicationnmap p :let * = substitute(*,:print:g)*p Re-Formatting textgq Format a paragraphgqapggVGgq Reformat enti
13、re fileVgq current line break lines at 70 chars, if possible after a ;s/.,69;s*|.,69s+/&r/g Operate command over multiple filesargdo %s/foo/bar/e operate on all files in :argsbufdo %s/foo/bar/ewindo %s/foo/bar/eargdo exe sort|w! include an external command Command line tricksgvim -h helpls | gvim -
14、edit a stream!cat xx | gvim - -c v/dd|3-9/d filter a streamgvim -o file1 file2 open into a split execute one command after opening filegvim.exe -c /main joe.c Open joe.c & jump to main execute multiple command on a single filevim -c %s/ABC/DEF/ge | update file1.c execute multiple command on a group
15、of filesargdo %s/ABC/DEF/ge | update *.c remove blocks of text from a series of filesargdo /begin/+1,/end/-1g/d | update Automate editing of a file (Ex commands in convert.vim)vim -s convert.vim file.c#load VIM without .vimrc and plugins (clean VIM)gvim -u NONE -U NONE -N Access paste buffer content
16、s (put in a script/batch file)gvim -c normal ggdG*p c:/aaa/xp print paste contents to default printers/=*/|hardcopy!|q! gvims use of external grep (win32 or *nix)grep somestring *.php creates a list of all matching files use :cn(ext) :cp(rev) to navigate listh grep GVIM Difference Function (Brillian
17、t)gvim -d file1 file2 vimdiff (compare differences)dp put difference under cursor to other filedoget difference under cursor from other file Vim trapsIn regular expressions you must backslash + (match 1 or more)In regular expressions you must backslash | (or)In regular expressions you must backslash
18、 ( (group)In regular expressions you must backslash (count)/fred+/ matches fred/freddy but not free/(fred)2,3/ note what you have to break v or very magic (usually) reduces backslashing/codes(n|s)*where normal regexp/vcodes(n|s)*where very magic pulling objects onto command/search line (SUPER)C-R pu
19、ll word under the cursor into a command line or searchC-A pull WORD under the cursor into a command line or search- pull small register (also insert mode)0-9a-z pull named registers (also insert mode)% pull file name (also #) (also insert mode)=somevar pull contents of a variable (eg :let sray=ray0-9 manipulating registerslet a=_ clear register alet a=let *=a copy register a to paste bufferf11qyy:let q=q.zzz-
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1