1

My vim have a auto indent future for C files. I can run it and :set nocindent to change this behaviour. I don’t know what to add to the global configuration file. I’ve tested these lines without effects.

set nocindent
set noautoindent
set nosmartindent
filetype indent off
filetype plugin indent off

I’m out of ideas. My vim version is 8.0.13 .

  • Have you tried to add these settings to /etc/vim/vimrc.local? – hschou Oct 16 '16 at 20:37
  • I don’t have any /etc/vim/vimrc.local but /etc/vimrc. – Michas Oct 16 '16 at 21:01
  • You have to create /etc/vim/vimrc.local yourself. – hschou Oct 18 '16 at 6:26
  • I created but it didn't work. – Michas Oct 18 '16 at 21:07
  • Well, I have to admit that I just traced vim to see which config files it read. Run these two commands strace -o vim.log -eopen vim foo exit vim and run grep "/etc/" vim.log then you will see the files read from /etc/. – hschou Oct 20 '16 at 7:25
0

Syntax and filetype plugins are able to override your default settings. The reason for this is that they are applied later, when the file is opened, as opposed to when vim starts.

To work around this, you can do something like:

autocmd FileType * set nocindent

Basically this results in calling set nocindent every time a file is opened.

Change the * to c if you only want this to apply to c files.

  • Doesn’t work for me. – Michas Oct 17 '16 at 18:20
0

@Michas: As far as I know, we can re-define our Vim's environment using the "-u" option inline with the vim command. For example:

1) Creating a file, say ~/.yourvim, with the following stuffs:

set nocindent
set noautoindent

2) Then add into your ~/.bashrc file this line

alias vim="vim -u ~/.yourvim"

3) Exit the current terminal, open a new one and you can try with the new vim's environment.

I am using this trick to define my own vim. Of course we can provide more options inside the "~/.yourvim" files as well as the "alias" command. So far, it works on my Debian 8 with vim version 7.4.

There is another way: modify or create (if it does not exists)

~/.vimrc

put the following lines into the latter file

set nocindent
set noautoindent

Exit the current terminal, open a new one and try. Good luck!

  • This hack is too complicated. The vim is too critical. – Michas Oct 17 '16 at 18:22

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.