我使用雷泰公司的Vim仅空间
:set noet|retab!
currentling但我遇到的是它的更换4个空格所有实例的标签在整个文件中的问题。 我需要vim只在行的开始处替换4个空格的实例。
如果我删除!在retab结束时,空间不会被替换。
我使用自定义功能,有人创建尝试:
" Retab spaced file, but only indentation
command! RetabIndents call RetabIndents()
" Retab spaced file, but only indentation
func! RetabIndents()
let saved_view = winsaveview()
execute '%[email protected]^\(\{'.&ts.'}\)\[email protected]\=repeat("\t", len(submatch(0))/'.&ts.')@'
call winrestview(saved_view)
endfunc
但我得到一个可爱的小错误信息,当我运行:检测
:RetabIndents
错误而处理功能RetabIndents :
第2行:
E486:找不到模式:^({4})+
你确定你还没有取代所有标签开始空间?你使用的是原始文件还是已经运行':set noet | retab!'的已修改文件(或缓冲区)? – gotgenes
好吧,这是问题,我没有任何空间来替换。如果找不到匹配,是不是应该忽略修饰符? –
另请参阅http://stackoverflow.com/questions/5144284/force-vi-vim-to-use-leading-tabs-only-on-retab – wimh