配置如下:
set nu
set cindent
set smarttab
set shiftwidth=4
set mouse=
nmap<c-v> "+p
vmap<c-c> "+y
nmap<c-a> ggVG
inoremap ( ()<Esc>i
inoremap [ []<Esc>i
inoremap { {}<Esc>i
inoremap ' ''<Esc>i
inoremap " ""<Esc>i
inoremap <Enter> <c-r>=P()<CR>
func P()
let a=getline('.')
let n=col('.')-2
if a[n]=='{'&&a[n+1]=='}'
return "\<Enter>\<Esc>zzO"
end
return "\<Enter>"
endf
func D()
let a=getline('.')
let n=col('.')-2
if index(["(","[","{","\"","\'"],a[n])!=-1&&index([")","]","}","\"","\'"],a[n+1])!=-1
return "\<Right>\<BS>\<BS>"
elseif a[n]=='{'&&match(a,'}')&&match(getline(line('.')+1),'}')!=-1
return "\<Esc>jddk$dla"
end
return "\<BS>"
endf

本文介绍了Vim编辑器的个性化配置,包括设置自动缩进、智能制表、快捷键映射等,以提升代码编辑效率。同时,定义了两个功能函数P()和D(),分别用于自动插入代码块和删除括号对,增强代码编辑体验。
2890

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



