Problem with VIM tabnew or new buffer which reset all changes


When using VIM, usually I use new buffer or newtab for opening several files. There some anomally where everytime I open another files, my Python indentation going wrong! I don’t know what happen and try spend several hours to find the problem.

Finally, I got the problem ! See this :

1
2
3
4
5
6
setlocal tabstop=4
setlocal softtabstop=4
setlocal shiftwidth=4
setlocal textwidth=80
setlocal smarttab
setlocal expandtab


Using setlocal in vimrc, it mean only works on single files only. When you using new tab or new buffers, then your configuration will be ignored!

So what the solution? using “set”. For instance :

1
2
3
4
5
6
set tabstop=4
set softtabstop=4
set shiftwidth=4
set textwidth=80
set smarttab
set expandtab

Now you will have no prolem with newtab on files or opening several files.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.