将以下内容加入~/.vimrc中,记得先备份
ifv:progname=~?"evim"
finish
endif
"UseVimsettings,ratherthenVisettings(muchbetter!).
"Thismustbefirst,becauseitchangesotheroptionsasasideeffect.
setnocompatible
"allowbackspacingovereverythingininsertmode
setbackspace=indent,eol,start
ifhas("vms")
setnobackup"donotkeepabackupfile,useversionsinstead
else
setbackup"keepabackupfile
endif
sethistory=50"keep50linesofcommandlinehistory
setruler"showthecursorpositionallthetime
setshowcmd"displayincompletecommands
setincsearch"doincrementalsearching
"ForWin32GUI:remove't'flagfrom'guioptions':notearoffmenuentries
"let&guioptions=substitute(&guioptions,"t","","g")
"Don'tuseExmode,useQforformatting
mapQgq
"Thisisanalternativethatalsoworksinblockmode,butthedeleted
"textislostanditonlyworksforputtingthecurrentregister.
"vnoremapp"_dp
"Switchsyntaxhighlightingon,whentheterminalhascolors
"Alsoswitchonhighlightingthelastusedsearchpattern.
if&t_Co>2||has("gui_running")
syntaxon
sethlsearch
endif
"Onlydothispartwhencompiledwithsupportforautocommands.
ifhas("autocmd")
"Enablefiletypedetection.
"Usethedefaultfiletypesettings,sothatmailgets'tw'setto72,
"'cindent'isoninCfiles,etc.
"Alsoloadindentfiles,toautomaticallydolanguage-dependentindenting.
filetypepluginindenton
"Puttheseinanautocmdgroup,sothatwecandeletethemeasily.
augroupvimrcEx
au!
"Foralltextfilesset'textwidth'to78characters.
autocmdFileTypetextsetlocaltextwidth=78
"Wheneditingafile,alwaysjumptothelastknowncursorposition.
"Don'tdoitwhenthepositionisinvalidorwheninsideaneventhandler
"(happenswhendroppingafileongvim).
autocmdBufReadPost*
/ifline("'/"")>0&&line("'/"")<=line("$")|
/exe"normalg`/""|
/endif
augroupEND
else
setautoindent"alwayssetautoindentingon
endif"has("autocmd")
本文详细介绍了如何通过修改Vim配置文件~/.vimrc来优化编辑体验,包括设置兼容性、撤销操作、历史记录、搜索高亮等功能,并针对不同操作系统进行了特定设置。
7074

被折叠的 条评论
为什么被折叠?



