Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [tab-characters]

Question about how to handle white spaces tab characters with vim, insert them, remove them, convert them to space characters, etc...

Filter by
Sorted by
Tagged with
0 votes
0 answers
35 views

How can i get visualize line indent every time i use tab or go to new line

I set set listchars=tab:\│\ set list to my vimrc and it shows like below But when I go to another file it doesn't have a vertical line indent. It just affected 1 file, I have no idea about this. ...
user avatar
0 votes
1 answer
90 views

Can't enter a tab character when previous character is not a tab or space in insert mode

When pressing tab in any language in edit mode, nothing happens if the character before the cursor is not a space or a tab. Doing ctrl-v tab works, but I don't want to have to do that every time and ...
user avatar
  • 111
0 votes
2 answers
204 views

How to convert spaces on a line to tabs?

I know there's a way because it happened by accident. I was frenetically moving in a short region of text and at some point, with some wrong keystroke, the leading spaces on the line became a tab (and ...
user avatar
  • 1,572
1 vote
1 answer
104 views

Stop vim from deleting expanded tab as a block of spaces

I am on CentOS 8.1 and using vim 8.0.1763. When I open a python file, e.g. vim tmp.py, I type tab and it inserts 4 spaces (see .vimrc below). When I type delete, it deletes all 4 spaces. I want it ...
user avatar
0 votes
1 answer
20 views

Why can't save file without tab key?

Configuration in my .vimrc: set tabstop=4 set expandtab set softtabstop=4 set shiftwidth=4 I have edit a file which contain tab,saved and reopen to have a look at it with set list,the tab key saved,...
user avatar
  • 820
1 vote
2 answers
196 views

Shouldn't `softtabstop` be set, when using option 2 in `:h tabstop` to configure Vim to use spaces for `<Tab>`s?

I want to configure Vim to use spaces for <Tab>s everywhere. Therefore, I've had a look at :h tabstop to figure out how to perform the configuration. Looking at the help text, option 2. seems ...
user avatar
  • 995
0 votes
1 answer
237 views

Neovim keeps reverting shiftwidth size after `after/ftplugin`

I like to code with 4 spaces as a tab. I added this to after/ftplugin/sass.vim: echom "before sass file settings" set shiftwidth=4 " <---- Problem setting, keeps changing back to 2 ...
user avatar
1 vote
1 answer
5k views

Fixing tab and space inconsistency

I used < in visual model to do a shift+tab reverse for a code inside loop after I removed the try/except phrase. Now, I get an error: $ python clean_captions.py File "clean_captions.py"...
user avatar
0 votes
1 answer
27 views

vim plugin changes rust files to use a ts of 4 rather than 2

Let's say I have a simple file, echo -n "\tTABBED ONCE" > foo.rs And then I have in my .vimrc the following, set ts=2 call plug#begin('~/.vim/plugged') call plug#end() How come I open that file ...
user avatar
0 votes
0 answers
25 views

Printed <tab> on pressing the tab key

It's not easy to articulate the question, as I touched something I don't understand. I am using a vim extension of VS-CODE. I pressed something, that turned my next pressed key, into a literal, ...
user avatar
0 votes
1 answer
335 views

Tabs and only tabs for any file type

I would like vim to only ever insert a space character when I touch the space bar. Instead vim decides that sometimes tabs should be 4 spaces. How do I force vim to always and forever use tabs ...
user avatar
2 votes
1 answer
165 views

escape, ctrl-w through citrix lite in browser

I need to be able to run vi on a machine that I access through Citrix lite in the browser. However I've come across a number of problems because of conflicts around esc and ctrl+w. Specifically, ...
user avatar
1 vote
2 answers
923 views

Pressing Enter removes indentation

If I have a file a.js like this: let a1 = [ ]; and I press Enter at the end of the first line, a Tab is inserted. I do not want this, so I added a setting: filetype indent off but then if I have ...
user avatar
  • 746
0 votes
1 answer
226 views

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

I am using the code getline(".")[col(".")-1] to get the character under the cursor. How can I check if the character under the cursor is a tab ?
user avatar
  • 125
2 votes
1 answer
218 views

Why can't I use a literal Tab as the {commands} for :normal?

I'd like to write the following code: function Normal(command) execute "normal!" a:command endfunction call Normal("\<C-O>") call Normal("\<C-I>") The first call to Normal succeeds, ...
user avatar
  • 27.4k
1 vote
1 answer
504 views

tabs after pastetoggle instead of spaces

Using following .vimrc " Just to see tab/spaces/endline clearly: set encoding=utf-8 set list set listchars=tab:▸\ ,eol:¬ nnoremap <F5> :set list!<cr> " Tab to spaces settings set tabstop=...
user avatar
2 votes
1 answer
331 views

How to view tabs as conventional whitespace, not as control character ^I (caret I) in VIm?

I've somehow managed to have all tabs show up as the control character ^I in VIm, specifically gvim 8.1.1 on Windows 10. All I have related to tabs in vimrc is this: set tabstop=2 I do also have ...
user avatar
  • 123
0 votes
1 answer
149 views

Expandtab converts spaces to newline character?

When I enabled expandtab in vim by putting these in .vimrc: set tw=4 set expandtab Vim comverted every space typed by me to a newline character. Like with the above settings whenever I type a new ...
user avatar
  • 103
1 vote
1 answer
621 views

How to show 2 spaces as tabs in listchar?

I like to see my indentation level with listchars=tab:\|\ But one project uses two spaces instead. Is there any way to show indentation level lines then? This question seems to the opposite of Show ...
user avatar
  • 13
2 votes
1 answer
40 views

On the length of tabs after an initial character

Length of tabs after initial char Start gvim with the --clean option, to get a clean slate, and then do: :set noet ts=5 sts=3 sw=2 Then enter the following 1234567890 and on the next line, press ...
user avatar
  • 123
1 vote
0 answers
267 views

The tab adds 8 spaces even though `set tabstop?` returns 4

For some reasons when I'm editing my ~/.config/nvim/init.vim, it adds 8 spaces even though I set set tabstop=4 on the file. Actually, :verbose set tabstop returns 4, so it should be 4 spaces. I ...
user avatar
  • 447
1 vote
1 answer
156 views

Tab multiple lines [duplicate]

I have my tab set to 4 spaces with :set tabstop=4. Now I want to highlight multiple lines and tab them, or indent all them 4 spaces. If I highlight the lines and do >, it seems to indent them more ...
user avatar
0 votes
1 answer
515 views

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

If I want to change the tab size, I can do that with set tabstop=<number>. I have that in my .vimrc to make it 4 instead of 8. However, when I indent/deindent text by highlighting it then using ...
user avatar
  • 103
1 vote
0 answers
434 views

Set tab width according to file [duplicate]

I have the following in my .vimrc: set expandtab "Use soft tabs (spaces) set shiftwidth=2 "Set tab width = 2 set softtabstop=2 "Set tab width = 2 set autoindent "Set indent of previous line Now if I ...
user avatar
  • 111
1 vote
1 answer
871 views

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

I like to indent my shell scripts with two spaces instead of a TAB. So, I set setlocal shiftwidth=2 in ~/.vim/after/ftplugin/sh.vim. It works, but I noticed that when the indentation level gets ...
user avatar
  • 113
0 votes
1 answer
1k views

how to make vim indentation file type specific? [duplicate]

I usually work on js files and php files. My js files require 2 spaces tab, whereas my php requires 4. How can I make vim dynamically change that depending on the file type I'm working on?
user avatar
  • 539
0 votes
1 answer
399 views

Search for 2 but not for 3 tab characters

I want to search in Vi for two tabs but not for three or more tabs. I tried several things like this: /\t\t\(\t\)@! But nothing works. Any idea?
user avatar
  • 143
3 votes
2 answers
3k views

Getting Shift-Tab to work in VIM Insert mode

I've been trying to get Shift+Tab or <S-Tab> to work in VIM and I can't figure it out. I read this document, but the remap solution only works for normal mode (because if I press Shift+Tab, VIM ...
user avatar
  • 1,247
7 votes
1 answer
80 views

Why are tabs adjacent to concealed tabs displayed wider than a single tabstop?

I just wrote the following code in an answer to another question: syntax match HideTwoIndents /\v^\t(\t)?/ conceal set conceallevel=2 This works great if 'list' is set and if 'listchars' does not ...
user avatar
  • 27.4k
1 vote
1 answer
384 views

Tab size fixed to 8 in spite of polyglot.

I am using Vim 8. Since I installed vim-polyglot to handle syntax highlighting and indentation of different languages without going crazy, whatever file I open has a tab size of 8 automatically. I ...
user avatar
  • 123
1 vote
0 answers
116 views

Files with tabs are length 8 even with set tabstop=4 in vimrc [duplicate]

I have most of the usual tab commands in ~/.vimrc: set tabstop=4 set softtabstop=4 set shiftwidth=4 set expandtab set breakindent set autoindent set smartindent. There are no problems when I open a ...
user avatar
53 votes
1 answer
106k views

Setting TAB to 2 spaces

I've looked through various answers which imply that setting the following in .vimrc would be appropriate to force tab insertions to become spaces. filetype plugin indent on " On pressing tab, ...
user avatar
5 votes
2 answers
4k views

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

My current configuration makes vim automatically expand TAB to 4 spaces for me: " Define tab as 4 spaces " Taken from http://stackoverflow.com/questions/1878974/redefine-tab-as-4-spaces set tabstop=4 ...
user avatar
  • 195
1 vote
2 answers
1k views

Have backspace delete whole tabs

Under regular conditions, the tab key will insert a tab character and backspacing that tab deletes the whole tab character. I have set up expandtab and softtabstop=4 so that when I hit tab it will ...
user avatar
  • 113
1 vote
0 answers
978 views

expandtab / noexpandtab toggles by itself in Neovim

I have this issue where noexpandtab turns itself on after a while. Tried to describe it here and in the Github Issue because I am not 100% sure this is a legit bug. For a long time, I have ...
user avatar
  • 2,212
0 votes
1 answer
2k views

<Tab> in insert mode brings up completion

Today when I open my computer and enter vi, strange things happened: backspace not working(solved), and Tab brings up keyword completion in insert mode, which is what I'm worrying about. Before, I can ...
user avatar
  • 267
-1 votes
2 answers
2k views

bypassing TAB auto-complete

Sometimes I need to press TAB, but instead of getting actual the tab key, a suggestion pops up and TAB cycles through the suggestions. How can I insert TAB without invoking the auto-completion ? The ...
user avatar
  • 879
2 votes
2 answers
1k views

Show leading whitespaces, but not including tabs

I am a tabs kind of guy, I do not like when my code contains leading whitespaces instead of leading tabs. I often exchange codes with colleagues and I first have to convert the leading whitespaces to ...
user avatar
  • 343
10 votes
3 answers
1k views

Shift left or right (with `noet`) without converting existing spaces to tabs

Foreword I'm using the "indent with tabs, align with spaces" ideology for indentation. This means that each line in a file can be prefixed with an arbitrary amount of tabs and spaces (as opposed to "...
user avatar
  • 295
1 vote
2 answers
292 views

How can I highlight misuse of tabs and spaces according to current configuration?

I'm looking for a way that will highlight lines (or part of lines) that don't adhere to current tabs settings. Say for instance, I have the following configuration in my .vimrc tabstop=8 ...
user avatar
  • 879
4 votes
2 answers
3k views

softtabstop == tabstop VS softtabstop=0

Are this: set noexpandtab set shiftwidth=4 set tabstop=4 set softtabstop=0 ..and this: set noexpandtab set shiftwidth=4 set tabstop=4 set softtabstop=4 ..exactly the same? I thought that if ...
user avatar
  • 885
1 vote
1 answer
52 views

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

So when I go to the first character in a line, the first character in that line is a tab character, and I execute echo col('.'), I will get 1. However when I type 2| I won't go to the next character, ...
user avatar
  • 1,804
2 votes
2 answers
1k views

Transforming a long table into multiple columns

Suppose I have the following table: E 12.02 T 9.10 A 8.12 O 7.68 I 7.31 N 6.95 S 6.28 R 6.02 H 5.92 D 4.32 L 3.98 U 2.88 C 2.71 M 2.61 F 2.30 Y 2.11 W 2.09 G 2.03 ...
user avatar
9 votes
3 answers
8k views

Vim doesn't use the correct indentation in Python files

I have encountered something that I have never seen before in Vim. While I was tentatively modifying some of the source code for software I've been planning to work on, I noticed vim was displaying ...
user avatar
  • 193
5 votes
4 answers
3k views

Delete indenting spaces one at a time

I want to be able to delete indenting spaces one at a time. If I set shiftwidth to 4, it deletes 4 spaces at a time if vim counts them as indentation. Setting shiftwidth to 1 fixes the problem, but ...
user avatar
  • 61
6 votes
1 answer
706 views

vimrc tab behavior when noexpandtab and softtabstop is less than tabstop

Questions In the following example: Why in the first line, a \t is inserted but only 4-col blank is displayed? Shouldn't it be 8 according to tabstop? Why the two <TAB> hits in the first line ...
user avatar
  • 163
1 vote
1 answer
101 views

How to write literal for Tab key to use for motion?

I've the following dummy file created via: echo -e "a a\tb b\tc c" > file Is there any literal for space which I can use for motion argument? For example this works (which removes the 1st a a ...
user avatar
  • 16.5k
4 votes
1 answer
524 views

How can I set expandtab but only for git commit messages?

Most of the time I'd like noexpandtab on because our corporate formatting uses tabs instead of spaces, so in my .vimrc I have this: " Set tab width stuff set tabstop=4 softtabstop=0 noexpandtab ...
user avatar
4 votes
3 answers
810 views

Avoid spaces getting converted to tabs automatically during shift(>>)

I use 2 spaces as indentation. So I set shiftwidth using :set sw=2. However when I do the shift operator(>>) on a line twice, the indentation converts the 4 spaces automatically to a tab. So to ...
user avatar
18 votes
3 answers
2k views

Tabs for indentation, spaces for alignment

I am trying to make vim auto indent with tabs, and align with whitespaces, but actually, vim indent with tabs and fill the alignment with tabs + white spaces. Vim does it : (each block is a tab) { &...
user avatar
  • 533