要在 vim 中的每一行的开头添加一个制表符,请在命令模式下键入以下内容(按 escape 进入命令模式):
:%s/^/<TAB>/g
键入时,您应该会在屏幕底部的 a 旁边看到该命令:
。该选项卡可能会被替换为^I
(或类似的东西。)
%
意味着文件中的每一行
s
表示替代(如搜索/替换)
- 字符分隔
/
搜索和替换模式
^
表示行的开头(这是我们要替换的模式)
<TAB>
是我们要用于替换的模式
g
意味着在全球范围内进行(我认为)
这是一个示例 .vimrc 文件(您可以粘贴到新文件中的内容):
" this is a comment
"
"
" set autoindent (indent the next line the same
" as the line before it)
"
" this feature will be very helpful if you choose
" to indent the file manually, which would be a great
" way to learn vi
set ai
" set tabstop and shiftwidth to 4
"
set ts=4
set sw=4
" expand tabs into multiple spaces
"
set expandtab
" highlight text when you search for it
" you can search a file in vi by pressing "/"
" then typing a search term
set hlsearch
" turn off the annoying feature that causes
" the screen to bounce all over the place
" as you're typing a search term
set noincsearch