vim与gvim技巧4Word下载.docx
《vim与gvim技巧4Word下载.docx》由会员分享,可在线阅读,更多相关《vim与gvim技巧4Word下载.docx(13页珍藏版)》请在冰豆网上搜索。
bn
gotonextbuffer
bp
gotopreviousbuffer
wn
savefileandmovetonext(super)
wp
savefileandmovetoprevious
bd
removefilefrombufferlist(super)
bun
Bufferunload(removewindowbutnotfromlist)
baddfile.c
filefrombufferlist
b3
gotobuffer3
bmain
gotobufferwithmaininnameegmain.c(ultra)
savphp.html
Savecurrentfileasphp.htmland"
move"
tophp.html
sav!
%<
.bak
SaveCurrentfiletoalternativeextension(oldway)
%:
r.cfm
SaveCurrentfiletoalternativeextension
sav%:
s/fred/joe/
doasubstituteonfilename
s/fred/joe/:
r.bak2
doasubstituteonfilename&
ext.
mv%%:
r.bak
renamecurrentfile(DOSuseRenameorDEL)
e!
returntounmodifiedfile
wc:
/aaa/%
savefileelsewhere
e#
editalternativefile(alsocntrl-^)
rew
returntobeginningofeditedfileslist(:
args)
brew
bufferrewind
spfred.txt
openfred.txtintoasplit
sball,:
sb
Splitallbuffers(super)
scrollbind
ineachsplitwindow
map
<
F5>
ls<
CR>
e#:
PressingF5listsallbuffer,justtypenumber
sethidden
Allowstochangebufferw/osavingcurrentbuffer
Quickjumpingbetweensplits
map<
C-J>
C-W>
j<
_
C-K>
k<
Recording(BESTTIPofALL)
qq
#recordtoq
yourcomplexseriesofcommands
q
#endrecording
@qtoexecute
@@toRepeat
5@@toRepeat5times
editingaregister/recording
qp
displaycontentsofregisterq(normalmode)
<
ctrl-R>
displaycontentsofregisterq(insertmode)
youcannowseerecordingcontents,editasrequired
qdd
putchangedcontactsbackintoq
@q
executerecording/registerq
OperatingaRecordingonaVisualBLOCK
1)definerecording/register
qq:
s/to/from/g^Mq
2)DefineVisualBLOCK
V}
3)hit:
andthefollowingappears
'
>
4)Completeasfollows
norm@q
combiningarecordingwithamap(toendupincommandmode)
nnoremap]@q:
w!
bar>
bd
Visualisthenewestandusuallythemostintuitiveeditingmode
Visualbasics
v
entervisualmode
V
visualmodewholeline
C-V>
enterVISUALBLOCKmode
gv
reselectlastvisualarea(ultra)
o
navigatevisualarea
*y
yankvisualareaintopastebuffer
V%
visualisewhatyoumatch
V}J
JoinVisualblock(great)
V}gJ
JoinVisualblockw/oaddingspaces
Deletefirst2charactersof10successivelines
0<
c-v>
10j2ld
howtocopyasetofcolumnsusingVISUALBLOCK
visualblock(AKAcolumnwiseselection)(NOTBYordinaryvcommand)
thenselect"
column(s)"
withmotioncommands(win32<
C-Q>
thenc,d,y,retc
howtooverwriteavisual-blockoftextwithanothersuchblock
Pickthefirstblock:
ctrl-vmove"
ay
Pickthesecondblock:
ctrl-vmovecctrl-o"
aP<
esc>
_vimrcessentials
setincsearch:
jumpstosearchwordasyoutype(annoyingbutexcellent)
setwildignore=*.o,*.obj,*.bak,*.exe:
tabcompletenowignoresthese
setshiftwidth=3
forshift/tabbing
setvbt_vb="
.
setsilent(nobeep)
setbrowsedir=buffer
MakiGUIFileOpenusecurrentdirectory
launchingWinIE
nmap,f:
update<
silent!
startc:
\progra~1\intern~1\iexplore.exefile:
//%:
p<
nmap,i:
!
\progra~1\intern~1\iexplore.exe<
cWORD>
FTPingfromVIM
cmap,r
Nreadftp:
//209.51.134.122/public_html/index.html
cmap,w
Nwriteftp:
gvimftp:
//#usesnetrw.vim
appendingtoregisters(useCAPITAL)
yank5linesinto"
a"
thenaddafurther5
a5yy
10j
A5yy
[I
showlinesmatchingwordundercursor<
cword>
(super)
ConventionalShifting/Indenting
b>
visualshifting(builtin-repeat)
vnoremap<
gv
vnoremap>
>
Blockshifting(magic)
i{
a{
also
%and<
%
Redirection&
Pasteregister*
redir@*
redirectcommandstopastebuffer
redirEND
endredirect
redir>
out.txt
redirecttoafile
WorkingwithPastebuffer
*yy
yanktopaste
*p
insertfrompastebuffer
yanktopastebuffer(exmode)
by*
Yankrangeintopaste
%y*
Yankwholebufferintopaste
.y*
YankCurrentlinetopaster
filternon-printablecharactersfromthepastebuffer
usefulwhenpastingfromsomeguiapplication
nmap<
leader>
p:
let@*=substitute(@*,'
[^[:
print:
]]'
g'
)<
cr>
*p
Re-Formattingtext
gq}
Formataparagraph
gqap
ggVGgq
Reformatentirefile
Vgq
currentline
breaklinesat70chars,ifpossibleaftera;
s/.\{,69\};
\s*\|.\{,69\}\s\+/&
\r/g
Operatecommandovermultiplefiles
argdo%s/foo/bar/e
operateonallfilesin:
args
bufdo%s/foo/bar/e
windo%s/foo/bar/e
argdoexe'
sort'
|w!
includeanexternalcommand
Commandlinetricks
gvim-h
help
ls|gvim-
editastream!
catxx|gvim--c"
v/^\d\d\|^[3-9]/d"
filterastream
gvim-ofile1file2
openintoasplit
executeonecommandafteropeningfile
gvim.exe-c"
/main"
joe.c
Openjoe.c&
jumpto"
main"
executemultiplecommandonasinglefile
vim-c"
%s/ABC/DEF/ge|update"
file1.c
executemultiplecommandonagroupoffiles
argdo%s/ABC/DEF/ge|update"
*.c
removeblocksoftextfromaseriesoffiles
argdo/begin/+1,/end/-1g/^/d|update"
Automateeditingofafile(Excommandsinconvert.vim)
vim-s"
convert.vim"
file.c
#loadVIMwithout.vimrcandplugins(cleanVIM)
gvim-uNONE-UNONE-N
Accesspastebuffercontents(putinascript/batchfile)
gvim-c'
normalggdG"
*p'
c:
/aaa/xp
printpastecontentstodefaultprinter
s/^/\=@*/|hardcopy!
|q!
gvim'
suseofexternalgrep(win32or*nix)
grepsomestring*.php
createsalistofallmatchingfiles
use:
cn(ext):
cp(rev)tonavigatelist
hgrep
GVIMDifferenceFunction(Brilliant)
gvim-dfile1file2
vimdiff(comparedifferences)
dp
"
put"
differenceundercursortootherfile
do
get"
differenceundercursorfromotherfile
Vimtraps
Inregularexpressionsyoumustbackslash+(match1ormore)
Inregularexpressionsyoumustbackslash|(or)
Inregularexpressionsyoumustbackslash((group)
Inregularexpressionsyoumustbackslash{(count)
/fred\+/
matchesfred/freddybutnotfree
/\(fred\)\{2,3}/
notewhatyouhavetobreak
\vorverymagic(usually)reducesbackslashing
/codes\(\n\|\s\)*where
normalregexp
/\vcodes(\n|\s)*where
verymagic
pullingobjectsontocommand/searchline(SUPER)
C-R>
pullwordunderthecursorintoacommandlineorsearch
C-A>
pullWORDunderthecursorintoacommandlineorsearch
-
pullsmallregister(alsoinsertmode)
[0-9a-z]
pullnamedregisters(alsoinsertmode)
%
pullfilename(also#)(alsoinsertmode)
=somevar
pullcontentsofavariable(eg:
letsray="
ray[0-9]"
manipulatingregisters
let@a=@_
clearregistera
let@a="
let@*=@a
copyregisteratopastebuffer
f11>
qyy:
let@q=@q."
zzz"
--------------