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
32 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
  • 491
29 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
  • 391
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
  • 49.6k
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.7k
6 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
  • 61
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,733
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
  • 14k
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.8k
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
  • 49.6k
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,624
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,086
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

How to replace tabs with spaces?

Try using: expand -t 4 input_filename output_filename expand is a command-line tool to convert tabs to spaces, which you can run from a shell or with :!expand. It's in POSIX so it should be ...
Ankit Shah's user avatar
3 votes

Tabs for indentation, spaces for alignment

The Smart Tabs plug-in that you mentioned is about as good as it gets. I initially ran into the same error that you did and gave up but eventually spent a few minutes to fix it. Try applying the ...
MartinR's user avatar
  • 31
3 votes

Tabs for indentation, spaces for alignment

Doing this truly automatically is difficult. Vim doesn't know what is "indentation" and what is "alignment"; and some people may disagree on what exactly constitutes indentation and alignment. That ...
Martin Tournoij's user avatar
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.5k
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.5k
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

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