I create the file "tabtest" by vi tabtest
and then typing:
a
tab
b
newline
c
tab
d
CTRL-C
:
wq
I have set expandtab
in my `.vimrc. But I'm still getting tabs in the file instead of spaces.
(base) balter@ab-rstudio:~$ cat -A tabtest
a^Ib$
^Ic^Id$
(base) balter@ab-rstudio:~$ cat .vimrc
let python_highlight_all = 1
set undodir=${HOME}/.vim/undo/
set backupdir=${HOME}/.vim/backup/
set directory=~/.vim/swp/
set writebackup
set noswapfile
set autoindent
set showmatch
set mouse=a
syntax on
set tabstop=4
set softtabstop=0
set shiftwidth=4
set textwidth=79
set expandtab
set smarttab
set autoindent
set fileformat=unix
set backspace=indent,eol,start
set whichwrap+=<,>,h,l,[,]
set laststatus=2
set statusline+=%F
colorscheme murphy
set paste
One of the golden rules of tool customization is to only put stuff you understand in your config. The first step toward that understanding is to read (not skim) the documentation for any option or command you plan to add and then, armed with that newfound knowledge, ponder the pros and cons of doing so.
:help 'paste'
is a very powerful option with many explicitly documented side effects, such as:
When the 'paste' option is switched on (also when it was already on):
[...]
- 'expandtab' is reset
[...]
That option should never be set in one's vimrc
because of all those nasty side effects that are desirable only when using the terminal/system's pasting facilities but very undesirable the rest of the time. Remove it.
Here is how it generally goes:
paste
option, and never bothers to read its documentation,:set paste<CR><whatever>:set nopaste<CR>
dance and decides to add set paste
to their vimrc
so that it is always on,set paste
to their vimrc
… because they have no idea of what the option actually does,set paste
and led them to :help 'pastetoggle'
, which solves the repetitiveness issue nicely without adding set paste
to their vimrc
,But, of course, the real solution is to get a proper Vim with clipboard support, but that's another, beaten to death, story.