Vim:缩进可以在非空白之后使用空格吗?
当光标前面有非空白字符时,是否可以让VIM使用空格作为制表符 例如: (假设TAB是Vim:缩进可以在非空白之后使用空格吗?,vim,Vim,当光标前面有非空白字符时,是否可以让VIM使用空格作为制表符 例如: (假设TAB是-->,•是一个空格。) 否则,当按tab键时,我需要真正的tab键 当制表符用于初始缩进,但所有文本的对齐方式都使用空格时,这很有用。使用:设置expandtab 这将在插入期间将所有制表符扩展到空格,甚至是行首的制表符(这可能是最好的)。 使用CTRL-V插入选项卡 从vim帮助(:帮助展开选项卡) 其他感兴趣的设置有softtabstop、tabstop和autoindent如果没有脚本或插件,这是不可能自
-->
,•
是一个空格。)
否则,当按tab键时,我需要真正的tab键
当制表符用于初始缩进,但所有文本的对齐方式都使用空格时,这很有用。使用
:设置expandtab
这将在插入期间将所有制表符扩展到空格,甚至是行首的制表符(这可能是最好的)。
使用
CTRL-V
插入选项卡
从vim
帮助(:帮助展开选项卡
)
其他感兴趣的设置有
softtabstop
、tabstop
和autoindent
如果没有脚本或插件,这是不可能自动完成的
“智能标签”插件就是为这个任务设计的
为了减少问题的发生频率,有内置的
preserveindent
和copyindt
选项,以防止在设置expandtab
时丢失现有的选项卡缩进。感谢您的回答,请回复:甚至是行开头的缩进(这可能是最好的).
-正是我不想要的。我意识到我的问题的答案很可能是“VIM不能这样做”。@ideasman42键映射(noremap:set invexpandtab expandtab?
)会有帮助吗?这将允许您在需要时打开和关闭expandtab
。然而,可能有更好的解决办法。
--->function(arg);••••••/* comment */
// ^ use spaces when pressing TAB after non-whitespace chars.
'expandtab' 'et' boolean (default off)
local to buffer
{not in Vi}
In Insert mode: Use the appropriate number of spaces to insert a
<Tab>. Spaces are used in indents with the '>' and '<' commands and
when 'autoindent' is on. To insert a real tab when 'expandtab' is
on, use CTRL-V<Tab>. See also :retab and ins-expandtab.
NOTE: This option is reset when 'compatible' is set.
'shiftwidth' 'sw' number (default 8)
local to buffer
Number of spaces to use for each step of (auto)indent. Used for
'cindent', >>, <<, etc.