How to insert tab character when expandtab option is on in Vim

后端 未结 3 1581
孤街浪徒
孤街浪徒 2021-01-29 17:14

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

3条回答
  •  不知归路
    2021-01-29 17:53

    You can disable expandtab option from within Vim as below:

    :set expandtab!
    

    or

    :set noet
    

    PS: And set it back when you are done with inserting tab, with "set expandtab" or "set et"

    PS: If you have tab set equivalent to 4 spaces in .vimrc (softtabstop), you may also like to set it to 8 spaces in order to be able to insert a tab by pressing tab key once instead of twice (set softtabstop=8).

提交回复
热议问题