Skip to main content
Share Your Experience: Take the 2024 Developer Survey
38 votes

How can I display tabs as characters?

Highlighting tabs Temporary Tab highlighting For occasional use, one can simply highlight all tabs in a document using the following search / command: /\t To remove the highlighting, simply type :noh ...
Serge Stroobandt's user avatar
33 votes
Accepted

Setting TAB to 2 spaces

Have you sourced your .vimrc since making these changes? When having vim open just type source ~/.vimrc (assuming it is in it's default location) EDIT: This could help too
Gleland's user avatar
  • 501
30 votes

What is `softtabstop` used for?

The value of 'softtabstop' equals how many columns (=spaces) the cursor moves right when you press <Tab>, and how many columns it moves left when you press <BS> (backspace) to erase a tab. ...
Arminius's user avatar
  • 401
17 votes
Accepted

Vim doesn't use the correct indentation in Python files

It gets reset by the Python filetype plugin; from /usr/share/vim/vim74/ftplugin/python.vim: " As suggested by PEP8. setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8 This file is loaded ...
Martin Tournoij's user avatar
10 votes

Elastic Tabstops in Vim?

From the comments: since version 8.1.105, vim has +vartabs compile-time feature, thanks to Christian Brabandt ! As far as I can see, this allows implementing elastic tabstops. See the actual pull ...
ulidtko's user avatar
  • 223
10 votes

How can I display tabs as characters?

I personally like the use of the plugin indentLine, which displays a vertical line at indentation levels. It is of great help especially in python, where the indentation is important. Among other ...
mike's user avatar
  • 949
9 votes

Transforming a long table into multiple columns

If you want to do that in vim you can use the following macro: qa^V3j$d"_4dd^V3jI<tab><Esc>Pq Which can be decomposed like this: qa Record the macro in the register a ^V ...
statox's user avatar
  • 50k
7 votes

softtabstop == tabstop VS softtabstop=0

As mentioned in :h softtabstop, the softtabstop indicates how many columns vim uses when you enter <Tab> in insert mode. Although it performs like <Tab> inserted, in fact, the vim mixes &...
Wei Fu's user avatar
  • 71
7 votes

What is `softtabstop` used for?

See the example below, // Start vim without loading your vimrc. set only tabstop=8 softtabstop=4. // This makes <Tab> in insert mode equals to 4 <Space> length at max. // In insert mode, ...
Chen XI's user avatar
  • 101
7 votes
Accepted

Expand <TAB> into 2 spaces when and only when editing HTML

Put this in your .vimrc file: autocmd BufRead,BufNewFile *.htm,*.html setlocal tabstop=2 shiftwidth=2 softtabstop=2 Briefly, autocmds get processed when the specified events occur for the specified ...
B Layer's user avatar
  • 19.9k
6 votes
Accepted

Fixing tab and space inconsistency

The problem occurred because there is an inconsistency between the spaces and tabs used for indentation in your code. You have probably opened a tab indented code, and started editing it, while vim ...
Soheil Gharatappeh's user avatar
5 votes

How can I display tabs as characters?

You may want to show tabs differently in a regular terminal and gvim. set list! if has('gui_running') set listchars=tab:▶\ ,trail:·,extends:\#,nbsp:. else set listchars=tab:>.,trail:.,...
ideasman42's user avatar
  • 3,743
5 votes

How can I display tabs as characters?

This can be easily achieved using listchars by specifying the tab as: ,tab:\ \ ┊, By providing two escaped spaces in front of your tab declaration, vim will repeat the spaces. This is opposed to the ...
Swivel's user avatar
  • 151
5 votes
Accepted

Auto-indent with spaces, but insert TAB when I press the TAB key

You can always type a literal tab using <c-v><tab>. Thus, you can set expandtab to always keep indent spaces, and use inoremap <tab> <c-v><tab> to always insert a tab ...
Mass's user avatar
  • 14.1k
5 votes
Accepted

How to check if the character under the cursor is a tab?

Just compare the character you got with a tab, which can be represented with the \t escape sequence. That is, getline(".")[col(".")-1] == "\t" The expression will return 1 if the character is tab, 0 ...
itub's user avatar
  • 266
4 votes
Accepted

softtabstop == tabstop VS softtabstop=0

Think of 'softtabstop' as an additional control over 'tabstop', allowing you to reach indents "in between" tab stops. With your indent setting, you don't actually need that, so the value of '...
Ingo Karkat's user avatar
  • 17.9k
4 votes

Show leading whitespaces, but not including tabs

In addition to @grodzik's answer here are two points that might interest you: You can have vim showing the tabs and spaces characters. If you use: set list set listchars+=tab:>-,space:. You'll ...
statox's user avatar
  • 50k
4 votes
Accepted

how to make vim indentation file type specific?

Putting these in your .vimrc should do the trick: augroup FileTypeSpecificAutocommands autocmd FileType javascript setlocal tabstop=2 softtabstop=2 shiftwidth=2 autocmd FileType php setlocal ...
3N4N's user avatar
  • 5,754
3 votes

bypassing TAB auto-complete

You can always bypass the effects of a keypress by preceding it with a ctrl-v. For example, if you'd like to insert a literal escape character without returning to normal mode, you can do from insert ...
DJMcMayhem's user avatar
  • 17.7k
3 votes
Accepted

Make pipe behave like `col('.')`

This is just barely tested. So it might still have some bugs: func! Go(char) let ret = '/^.\{'. a:char. '}\%'. line('.'). "l/e\<cr>" return ret endfunc nnoremap <silent><expr&...
Christian Brabandt's user avatar
3 votes
Accepted

Transforming a long table into multiple columns

Using the *nix commands split and paste $ split -l 4 ip.txt op ; paste op* > ip.txt Or, from within vim as suggested by OP: :!split -l 4 % /tmp/split; paste /tmp/split* > %; rm /tmp/split*
Sundeep's user avatar
  • 1,096
3 votes

Vim doesn't use the correct indentation in Python files

Solution for me was to add this line after the filetype plugin on into my ~/.vimrc file filetype plugin on autocmd FileType python setlocal noexpandtab shiftwidth=4 softtabstop=4
Philippe Gachoud's user avatar
3 votes

How can I display tabs as characters?

I combined @john-om approach with this character Unicode Character 'ZERO WIDTH SPACE' (U+200B) and indentLine plugin. So, if I use spaces, plugin show nice formated indents, if I use tabs, pipes are ...
Michal Gonda's user avatar
3 votes

How to replace tabs with spaces?

For completeness, = could also be used to fix indentations, after you have specified that tabs are replaced with spaces. In normal mode, you can do so by typing :set expandtab. Then = could be used in ...
Samuel Li's user avatar
  • 131
3 votes

Delete indenting spaces one at a time

I think some of your confusion comes down to terminology. There are two separate characters, space " " and tab "\t". Tabs are a single character, but get displayed as several blank columns. This can ...
DJMcMayhem's user avatar
  • 17.7k
3 votes
Accepted

Getting Shift-Tab to work in VIM Insert mode

Thanks to @B Layer for their help. Turns out that all escape-prefixed keycodes (e.g. forward-delete, shift-tab, scroll-wheel-up, scroll-wheel-down) will fail for the mode in question if there is any ...
Luke Davis's user avatar
  • 1,397
3 votes
Accepted

Search for 2 but not for 3 tab characters

:/\t\t(\t)@! Your regular expression is almost valid, except that you need to use \@ instead of @. However first note, that using :/ means the cursor will be put on the line matching the regular ...
Christian Brabandt's user avatar
3 votes
Accepted

How to change the size of the indent that's created using ">" (forward arrow)?

See :h >: < >{motion} Shift {motion} lines one 'shiftwidth' rightwards. ...
muru's user avatar
  • 24.9k
3 votes
Accepted

Expandtab converts spaces to newline character?

You set the textwith (tw) to 4. So Vim breaks the lines. I guess you want shiftwidth: set shiftwidth=4 set tabstop=4 set expandtab
Ralf's user avatar
  • 9,247

Only top scored, non community-wiki answers of a minimum length are eligible