Hristo Venev
Hristo Venev

Reputation: 992

vim - fixed width tabs

<Tab>
<Space><Tab>

In this case the first tab has a width of tabstop characters but the second has the width of tabstop-1 characters. How do I make all tabs always be tabstop characters wide?

Upvotes: 0

Views: 218

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172570

The defining characteristic of tabstops is that they "snap" to certain positions (in Vim, multiples of the 'tabstop' setting). What you want is something different, and cannot be achieved (in any editor I know) with the \t = <Tab> = ASCII 0x09 character.

What you can do is define a mapping that inserts 'tabstop' amount of spaces when you press the Tab key:

:inoremap <expr> <Tab> repeat(' ', &tabstop)

(Of course, you can also choose another key for this, or make this buffer-local with <buffer>.)

Upvotes: 2

Related Questions