在 vim 中使用制表符而不是空格,即使使用“set Expandtab”
我通过 vi tabtest
创建文件“tabtest”,然后输入:
a
tab
b
newline
c
tab
d
CTRL-C
:
wq
I have set Expandtab
in my `.vimrc。但我仍然在文件中得到制表符而不是空格。
(base) balter@ab-rstudio:~$ cat -A tabtest
a^Ib$
^Ic^Id$
(base) balter@ab-rstudio:~$ cat .vimrc
let python_highlight_all = 1
set undodir=${HOME}/.vim/undo/
set backupdir=${HOME}/.vim/backup/
set directory=~/.vim/swp/
set writebackup
set noswapfile
set autoindent
set showmatch
set mouse=a
syntax on
set tabstop=4
set softtabstop=0
set shiftwidth=4
set textwidth=79
set expandtab
set smarttab
set autoindent
set fileformat=unix
set backspace=indent,eol,start
set whichwrap+=<,>,h,l,[,]
set laststatus=2
set statusline+=%F
colorscheme murphy
set paste
I create the file "tabtest" by vi tabtest
and then typing:
a
tab
b
newline
c
tab
d
CTRL-C
:
wq
I have set expandtab
in my `.vimrc. But I'm still getting tabs in the file instead of spaces.
(base) balter@ab-rstudio:~$ cat -A tabtest
a^Ib$
^Ic^Id$
(base) balter@ab-rstudio:~$ cat .vimrc
let python_highlight_all = 1
set undodir=${HOME}/.vim/undo/
set backupdir=${HOME}/.vim/backup/
set directory=~/.vim/swp/
set writebackup
set noswapfile
set autoindent
set showmatch
set mouse=a
syntax on
set tabstop=4
set softtabstop=0
set shiftwidth=4
set textwidth=79
set expandtab
set smarttab
set autoindent
set fileformat=unix
set backspace=indent,eol,start
set whichwrap+=<,>,h,l,[,]
set laststatus=2
set statusline+=%F
colorscheme murphy
set paste
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
工具定制的黄金规则之一是只将您理解的内容放入配置中。实现这种理解的第一步是阅读(而不是略读)您计划添加的任何选项或命令的文档,然后利用新发现的知识思考优点以及这样做的缺点。
:help 'paste'
是一个非常强大的选项,具有许多明确记录的副作用,例如:该选项永远不应在用户的
vimrc
中设置因为所有这些令人讨厌的副作用仅在使用终端/系统的粘贴功能时才需要,但在其余时间是非常不希望的。将其删除。一般情况是这样的:
paste
选项,但从不费心去阅读其文档中,:set Paste:set nopaste
舞蹈,并决定添加set Paste
到他们的vimrc
以便它始终处于打开状态,set Paste
添加到他们的 < code>vimrc…因为他们不知道该选项的实际作用,set Paste
和引导他们使用:help 'pastetoggle'
,它很好地解决了重复问题,而无需添加set Paste
对于他们的vimrc
,但是,当然,真正的解决方案是获得一个具有剪贴板支持的合适的 Vim,但那是另一个被殴打致死的故事了。
One of the golden rules of tool customization is to only put stuff you understand in your config. The first step toward that understanding is to read (not skim) the documentation for any option or command you plan to add and then, armed with that newfound knowledge, ponder the pros and cons of doing so.
:help 'paste'
is a very powerful option with many explicitly documented side effects, such as:That option should never be set in one's
vimrc
because of all those nasty side effects that are desirable only when using the terminal/system's pasting facilities but very undesirable the rest of the time. Remove it.Here is how it generally goes:
paste
option, and never bothers to read its documentation,:set paste<CR><whatever>:set nopaste<CR>
dance and decides to addset paste
to theirvimrc
so that it is always on,set paste
to theirvimrc
… because they have no idea of what the option actually does,set paste
and led them to:help 'pastetoggle'
, which solves the repetitiveness issue nicely without addingset paste
to theirvimrc
,But, of course, the real solution is to get a proper Vim with clipboard support, but that's another, beaten to death, story.