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 .

6
  • Have you tried to add these settings to /etc/vim/vimrc.local? Commented Oct 16, 2016 at 20:37
  • I don’t have any /etc/vim/vimrc.local but /etc/vimrc. Commented Oct 16, 2016 at 21:01
  • You have to create /etc/vim/vimrc.local yourself. Commented Oct 18, 2016 at 6:26
  • I created but it didn't work. Commented Oct 18, 2016 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/. Commented Oct 20, 2016 at 7:25

2 Answers 2

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.

1
  • Doesn’t work for me. Commented Oct 17, 2016 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!

1
  • This hack is too complicated. The vim is too critical. Commented Oct 17, 2016 at 18:22

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.