When I press enter and create a new line in vim while editing CSS, it gives me two tabs instead of just one

StackOverflow https://stackoverflow.com/questions/17917767

  •  04-06-2022
  •  | 
  •  

Frage

I debated with myself whether to post it on SuperUser but I did it here. When I have this in CSS, editing it in VIM:

#container {

then I press Return at the bracket to give me a new line, it sends the cursor two tabs to the left on the next line:

#container {
        |

Instead of like this, how I want it.

#container {
    |

how could I edit the .vimrc file to give me only one new tab on the next line instead of two?

My .vimrc file.

set ts=4
imap <C-Return> <CR><CR><C-o>k<Tab>
set cindent
set nocompatible
filetype indent plugin on
syntax on
set hidden
set wildmenu
set showcmd
set hlsearch
set ignorecase
set smartcase
set backspace=indent,eol,start
set autoindent
set nostartofline
set ruler
set laststatus=2
set confirm
set visualbell
set t_vb=
set mouse=a
set cmdheight=2
set number
set notimeout ttimeout ttimeoutlen=200
set pastetoggle=<F11>
set shiftwidth=2
set tabstop=1

map Y y$
nnoremap <C-L> :nohl<CR><C-L>

Thanks.

War es hilfreich?

Lösung

I believe your issue is that your shiftwidth is twice your tabstop. You are also setting tabstop twice, once at the top to 4 and again at the bottom to 1.

Try setting shiftwidth to the same at tabstop, there really aren't many cases that you'd want these two to be different.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top