在 Vim 中打开 expandtab 选项时如何插入制表符 [英] How to insert tab character when expandtab option is on in Vim
问题描述
当我处于插入模式并且我有 expandtab
选项已打开,按 Tab ↹ 会插入配置的空格数.
When I'm in insert mode and I have the expandtab
option switched on, pressing Tab ↹ results in inserting the configured number of spaces.
但有时我想插入一个实际的制表符.
But occasionally I want to insert an actual tab character.
你知道怎么做吗?
推荐答案
您可以在插入模式"下使用
.在插入模式下,
插入下一个字符的文字副本.
You can use <CTRL-V><Tab>
in "insert mode". In insert mode, <CTRL-V>
inserts a literal copy of your next character.
如果您需要经常这样做,@Dee`Kej 建议(在评论中)设置 Shift+Tab 以插入具有此映射的真实选项卡:>
If you need to do this often, @Dee`Kej suggested (in the comments) setting Shift+Tab to insert a real tab with this mapping:
:inoremap <S-Tab> <C-V><Tab>
此外,正如@feedbackloop 所指出的,在 Windows 上,您可能需要按
而不是
.
Also, as noted by @feedbackloop, on Windows you may need to press <CTRL-Q>
rather than <CTRL-V>
.
这篇关于在 Vim 中打开 expandtab 选项时如何插入制表符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!