4

When I am in a CSS file with a blank line, like this:

enter image description here

and I want to simply make a new line and move down to it, by hitting Enter , vim is auto inserting a tab character, e.g.

enter image description here

Running :set fo? inside the CSS file => formatoptions=croql.
If I disable all formatoptions with :set fo= - it still happens.
however if format options are disabled using :set paste vim does stop inserting the tab - but I dont want to have to work in paste mode all the time!

settings:

  • noautoindent
  • nosmartindent
  • nocindent

If I turn off filetype specific indenting with

filetype indent off

It still happens, what am I missing - do I need to restart vim or something for the settings to take effect?

How can I stop vim autoinserting these tab characters?

6

I found a couple of ways to solve the problem.

1. reload the buffer after running :filetype indent off

Vim's docs (:help :filetype-indent-off) provided an explanation:

You can disable :filetype indent on with:

:filetype indent off

This actually loads the file "indoff.vim" in 'runtimepath'. This disables auto-indenting for files you will open. It will keep working in already opened files. Reset 'autoindent', 'cindent', 'smartindent' and/or 'indentexpr' to disable indenting in an opened file.

  • "It will keep working in already opened files." - explained that I simply had to kill and reload the buffer after I ran the command :filetype indent off

2. Reset indentexpr

per docs

Reset 'autoindent', 'cindent', 'smartindent' and/or 'indentexpr' to disable indenting in an opened file.

it turned out the issue was caused by indentexpr which had the value of

indentexpr=GetCSSIndent()
Last set from /usr/share/vim/vim74/indent/css.vim

I was able to reset it with: :set indentexpr=""

which also fixed the problem.

-2

Yes this solved for me also this unkind effect:

I opened, and edited my ~/.vimrc

:filetype indent off

If you do not like the higlight scheme, you just search the selected colorscheme here:

/usr/share/vim/vim74/colors

i use generaly "colorscheme desert", in the 77-th row you find:

  hi Search cterm=NONE ctermfg=grey ctermbg=lightblue
  hi Search cterm=bold ctermfg=black ctermbg=green

that was for me better than the lightbue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.