有一段时间我在源文件中使用了tabstop = 4.现在我写了很多有深度缩进的javascript,一个4的tabstop似乎很浪费,所以我想把它转换为2.问题是我也使用"set expandtab".所以仅设置tabstop = 2,将无济于事.
关于如何将我的所有文件快速转换为tabstop 2的任何建议?
我目前相关的.vimrc设置是
set tabstop=4
set shiftwidth=4
set expandtab
Run Code Online (Sandbox Code Playgroud)
Alo*_*hal 11
你可以做
" convert spaces to tabs first
set noexpandtab
set tabstop=4
set shiftwidth=4
retab!
" now you have tabs instead of spaces, so insert spaces according to
" your new preference
set tabstop=2
set shiftwidth=2
set expandtab
retab!
Run Code Online (Sandbox Code Playgroud)
在vim窗口中,它将根据您的喜好重新收藏.您可以创建映射以使其更容易,或记录宏.可能有另一种方式,但上述方法应该有效.("是评论)