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
2answers
46 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 ...
0
votes
0answers
52 views

How to make tabs in vim work like they do in windows notepad

In notepad, whenever you hit tab, it will take up all the space up until the next "column". | | | | | # lets say these are the columns sdf f # Pressing "...
1
vote
1answer
61 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 ...
0
votes
1answer
17 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,...
1
vote
2answers
111 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 ...
0
votes
1answer
71 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 ...
0
votes
1answer
2k 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"...
0
votes
1answer
17 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 ...
0
votes
0answers
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, ...
0
votes
1answer
214 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 ...
2
votes
1answer
105 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, ...
1
vote
2answers
539 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 ...
0
votes
1answer
150 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 ?
2
votes
1answer
172 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, ...
1
vote
1answer
326 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=...
2
votes
1answer
232 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 ...
0
votes
1answer
110 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 ...
1
vote
1answer
477 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 ...
2
votes
1answer
34 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 ...
1
vote
0answers
161 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 ...
1
vote
1answer
141 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 ...
0
votes
1answer
399 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 ...
1
vote
0answers
424 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 ...
1
vote
1answer
619 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 ...
0
votes
1answer
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?
0
votes
1answer
288 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?
0
votes
2answers
2k 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 for the life of me I can't figure it out. I read this document, but the remap solution only works for normal mode (because if I ...
7
votes
1answer
73 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 ...
1
vote
1answer
315 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 ...
1
vote
0answers
114 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 ...
42
votes
1answer
82k 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, ...
5
votes
1answer
3k 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 ...
1
vote
2answers
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 ...
1
vote
0answers
799 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 ...
0
votes
1answer
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 ...
-1
votes
2answers
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 ...
2
votes
2answers
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 ...
8
votes
3answers
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 "...
1
vote
2answers
274 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 ...
4
votes
2answers
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 ...
1
vote
1answer
42 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, ...
2
votes
2answers
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 ...
8
votes
2answers
6k 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 ...
5
votes
4answers
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 ...
5
votes
1answer
659 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 ...
1
vote
1answer
95 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 ...
4
votes
1answer
474 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 ...
3
votes
3answers
684 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 ...
18
votes
3answers
1k 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) { &...
14
votes
2answers
10k views

Show listchars tab as spaces

I use list and listchars to show my whitespace, but the code style I adhere to uses tabs. Seeing > or ^I for all of my tabs is nauseating. How would I keep all of my existing list characters but ...