0

I have recently started using vim. I added :set tabstop=4 in my .vimrc to comply with the indentation scheme, but when I opened the file in another editor (gedit) it still uses 8 tab spaces. The formatting looks right inside vim. Any help how I can fix this?

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
VJune
  • 1,195
  • 5
  • 16
  • 26

3 Answers3

2

When setting tabstop it is also worth setting softtabstop and shiftwidth to the same value.
I set all the following at the same time (from my .vimrc file)

" tabstop:          Width of tab character
" expandtab:        When on uses space instead of tabs
" softtabstop:      Fine tunes the amount of white space to be added
" shiftwidth        Determines the amount of whitespace to add in normal mode
set tabstop     =4
set softtabstop =4
set shiftwidth  =4
set expandtab

Here is a great tutorial on how and why.
http://vimcasts.org/episodes/tabs-and-spaces/

Martin York
  • 257,169
  • 86
  • 333
  • 562
0

Make a similar change to the other editor. The width of the tab a property of the editor, not a property of the file.

pamphlet
  • 2,054
  • 1
  • 17
  • 27
0

You need to "convert" tabs to blanks, the following code solves your problem.

:set expandtab