我目前的设置是8个空格;我该如何重新定义它呢?
当前回答
:set sw=4
参见掌握VI编辑器
其他回答
我基本的~/。Vimrc评论:
set number " show line number
set tabstop=2 " set display width of tab; 1 tab = x space with
set expandtab " transform tab to x space (x is tabstop)
set autoindent " auto indent; new line with number of space at the beginning same as previous
set shiftwidth=2 " number of space append to lines when type >>
我复制并粘贴到我的。vimrc文件:
" size of a hard tabstop
set tabstop=4
" always uses spaces instead of tab characters
set expandtab
" size of an "indent"
set shiftwidth=4
前两个设置意味着当我按Tab键时,我得到4个空格。 第三个设置意味着当我做V>(即视觉和缩进)时,我也得到了4个空格。
不像公认的答案那么全面,但它可能会帮助那些只想复制和粘贴一些东西的人。
永久为所有用户(当你独自在服务器上时):
# echo "set tabstop=4" >> /etc/vim/vimrc
在配置文件中追加设置。 通常在新服务器apt-get清除纳米mc和所有其他节省您的时间。否则,你将在git、crontab等中重新定义编辑器。
还有一件事,使用 : retab 将现有制表符转换为空格 http://vim.wikia.com/wiki/Converting_tabs_to_spaces
对于永久的更改,创建文件~/.vim/plugin/tab_expander。用内容进行Vim
set tabstop=4 softtabstop=4 expandtab shiftwidth=4 smarttab
防止碰~/。Vimrc,从而保持其他默认设置不变。