I set the expandtab option to on, but still I don't get spaces when I click tab, but I get actual tab.

This is how I set it:

set expandtab

set shiftwidth=4

set softtabstop=4

First I thought as this question says that a plugin is override it, but I executed:

:verbose set expandtab?

and indeed I get that last set is the line in my vimrc

how can I solve it?

  • You don't seem to have an answer to this question, @JackThomson, and hopefully you've resolved it by now, but there's little information here to go on, and it can arise that you may deliberately or inadvertently set paste in addition to your vimrc settings. The paste setting also applies noexpandtab, and can cause this experience, but expandtab, if originally set, is restored once you set nopaste. Check :set paste?, it could be the answer.
    – NeilG
    Aug 18 at 2:11

1 Answer 1


There are two places you can set it: 1. $HOME/.vimrc 2. inline inside the file

.vimrc #1 This is the settings I'm using:

"indent settings
set shiftwidth=4
set softtabstop=4
set expandtab
set nocompatible  " <= vim, not vi

And it works for me, also make sure you're using vim not vi (?) ..

Inline #2

inline settings for vi supported only when using set modeline Meaning in your $HOME/.vimrc paste: set modeline and re-edit your file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .