Yes, use listchars: set list set listchars=tab:>- If you put these two lines in your .vimrc, tabs will be shown as > for the start position and - through the rest of the tab. (Sidenote: listchars can also show trailing spaces with trail:x (replace x with the character you want to use for a trailing space), which can be useful as well.)


You can use the :retab command. From :help :retab Replace all sequences of white-space containing a <Tab> with new strings of white-space using the new tabstop value given. If you do not specify a new tabstop size or it is zero, Vim uses the current value of 'tabstop'. [...] With 'expandtab' on, Vim replaces all tabs with the appropriate ...


The basic answer is :set list, which causes tabs to display as ^I. However, I recommend going beyond that. Just :set list is problematic in that it fails to preserve visual alignment on screen. For example: %.o: %.cpp ^Ig++ -c $< doesn't look good, especially when you expect the g of g++ to appear under the first p of cpp (assuming tabstop=8). ...


Instead of just pressing Tab, first press Ctrl-V and then press Tab. This can be used to insert a variety of special chars. See :help i_CTRL-V for details. Ctrl-V also works in command-line mode (:help c-CTRL-V), and even in some other programs entirely. (e.g. bash, mutt.) If you have Ctrl-V mapped to something else, try Ctrl-Q. This has the same effect ...


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 which is short for :nohlsearch —no high lighting. Permanent Tab highlighting " Highlight tabs as errors. " https://vi.stackexchange.com/a/9353/3168 ...


You can use :retab, as stated, however, this will change all tabs to spaces, not only tabs at the start of the line So this (where ⇥ is a tab character): if :; do ⇥echo "⇥hello" end gets changed to (where ␣ is a space character): if :; do ␣␣echo "␣␣hello" end This can produce unexpected side-effects in some scenarios, and it's even more of an issue when ...


'listchars' takes two characters for tab so you can simply use two regular spaces: set listchars=tab:\ \ ,trail:·,eol:¬,nbsp:_


Vim provides !retab command which will replace all sequences of <Tab> with new strings of white-space using the new tabstop (e.g. :set tabstop=2) value given, but all tabs inside of strings can be modified (e.g. in a C program, you should use \t to avoid this)! So alternatively you can change all tabs into spaces using the following command: :%s/\t/ ...


As the softtabstop documention mentions, it's useful if you want to keep the default tab stop size of 8, but edit a file as if the tab stop size was some other value. For example, if you wanted an indentation level of 4 while editing code, but some comments had tab-indented text such as a table that depended on a tab stop of 8, you could set sts to 4. One ...


Rather than change your behavior (which is error prone). I would set up vim to behave differently for this file type. So in my normal editing I expand tabs. But specifically for make files I set the noexpandtab so that tabs are retained. Add the following to your ~/.vimrc file: " Normal action set expandtab if has("autocmd") " If the filetype is ...


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


As far as I can tell there is no reasonable way to accomplish this in a plugin. There is a patch for it, but it's hard to predict when / if the patch will get merged.


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 every time a Python file is loaded. To override it add this in your vimrc: augroup python autocmd! " Add shiftwidth and/or softtabstop if you want to ...


It's only a clumsy workaround, but if you :set list the cursor will be positioned on the other "side" of the tab.


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 things, it provides a toggle command, that can be mapped to a key combination, so that you can turn it off, when you don't need it.


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. Thus, if 'tabstop' is 8, and 'softtabstop' is 4, all displayed tabs are 8 columns wide, but every press of the <Tab> key just gets you half a tab (=4 ...


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 request.


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 Enter visual block mode (use ctrl-v) 3j$ Select the lines you want to put in a column d Delete them "_4dd Delete the lines which ...


First possibility Add the following line to your .vimrc: autocmd FileType gitcommit setlocal expandtab Second possibility Create a file ~/.vim/after/ftplugin/gitcommit.vim and in there put: :setlocal expandtab See the faq: How do I configure Vim to automatically set the 'textwidth' option to a particular value when I edit mails How do I extend an ...


A tab advances to the next column whose position is a multiple of the tab stop. So, with tabstop=4, if your cursor is in column 7 and you press Tab, the cursor will advance only one column to column 8, as in the first tab in your example. Tabs are not constant width. You can visualize it thus—each ↓ is a tab stop, a column that is a multiple of 4: ↓ ↓...


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 file name patterns. Here we just set the tab values for the current buffer to the desired value in the event of reading or creating a file with .htm or .html ...


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, type 12, one <Tab>, 5. We get insertion below, 12··5 // Quit insert mode. Move cursor back, we find 2 <Space> inserted. // In insert mode, type 12,...


The cursor in normal mode is on the character not to either side. So you can do i and a to go to insert mode to the left or right of the tab respectively.


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 <BS> or <Tab> for that. If you hit <Tab> in insert mode, the vim will act like: if set expandtab always uses <BS> else if ...


Easiest method is to do :set list, which will show tabs as ^I and end of line as $. I like to use a mapping that calls :set invlist to toggle between regular display and list display. For example: :nmap <leader>l :set invlist<cr> This allows me to quickly check if there are tab vs space problems and then go back to a regular display.


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:.,extends:\#,nbsp:. endif (Adding for completeness, in case others find it useful).


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 if not.


Are you trying to remove the unnecessary spaces or are you just trying to format your code correctly. Because there are different solutions to the problem. Do correct formatting: You can get vim to correctly indent your code by using ={motion} command The easiest way to use this is to use visual mode. Go to the start of the section you want correctly ...


This command will remove all whitespaces on both sides of one or more tabs in every line of the current buffer: :%s/ *\([\t]\+\) */\1/g


You chose to have them displayed that way by adding the uhex setting to the 'display' option. You can :set display-=uhex to restore the default behavior of displaying them as ^I. Getting :reg to display them differently would require a Vim patch, but some plugins provide displays of the registers in a scratch buffer, which may help. Lord of the Regs ...

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