我使用雷泰公司的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