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...
68
questions
1
vote
2
answers
84
views
Why is Vim ignoring my `expandtab` setting?
In my vimrc, I have set expandtab. When I edit a Tex file, however, Vim inserts tab characters , instead of spaces , when I press tab. I figured noexpandtab must be set by the TeX ftplugin for some ...
1
vote
1
answer
62
views
change behaviour of > / < and >> / << to insert / remove only leading tabs
i want > / < and >> / << to simply insert and remove tab characters at the beginning of the line.
variant: i would even prefer to have> / < and >>/ << insert / ...
0
votes
1
answer
19
views
Manually indenting lines with tabs
Lines can be indented with tab characters. And it is quite obvious the there are better ways to do that than manually adding a tab character to the beginning of each line.
But how to discover these ...
1
vote
0
answers
42
views
Expand all non-leading tabs but keep leading tabs [duplicate]
I want to use tabs for indentation and spaces for alignment in the following way:
keep tab characters (like noexpandtab) for all leading tabs of a file, but
expand tabs (like expandtab) that occur ...
0
votes
3
answers
63
views
What is the setting for the strict tab adherence when running vim with no configuration?
When I run vim with no configuration (--clean), in a bash file I cannot move the cursor before any indented tabs. I remember being annoyed by this before I regularly used vim, but early on as I grew ...
1
vote
2
answers
117
views
How to get the right indent size in python lists?
In my vimrc I have filetype indent plugin on
When I write python code, the indentation mostly looks good, but in lists it is too big:
def fun():
return 'indent looks good'
my_list = [
'...
0
votes
0
answers
103
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. ...
1
vote
1
answer
999
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 ...
0
votes
2
answers
2k
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 ...
2
votes
1
answer
342
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
1
answer
37
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
2
answers
303
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
1
answer
611
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 ...
1
vote
1
answer
9k
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
1
answer
45
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
0
answers
28
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
1
answer
539
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
1
answer
260
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
2
answers
1k
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
1
answer
435
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
1
answer
310
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
1
answer
766
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
1
answer
520
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 ...
1
vote
1
answer
217
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
1
answer
753
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
1
answer
50
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
0
answers
810
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
1
answer
184
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
1
answer
712
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
0
answers
435
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 ...
2
votes
1
answer
1k
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 ...
1
vote
1
answer
2k
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
1
answer
621
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?
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 ...
7
votes
1
answer
86
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
1
answer
462
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
0
answers
118
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 ...
66
votes
2
answers
128k
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
2
answers
5k
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
2
answers
2k
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
0
answers
1k
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
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 ...
-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 ...
2
votes
2
answers
2k
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 ...
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 "...
1
vote
2
answers
308
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
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 ...
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, ...
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
...
9
votes
3
answers
10k
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 ...