A follow up to my other question here: Problem using gdb with vim over ssh

I was messing around trying to get my issues over ssh fixed, and I don't know what I did but now vim doesn't show any colour when I open a .c file I am working on

If I just type in vim there is colour in the default screen that pops up, but when I open the .c file it's just white text on black background. If I enable line numbers using :set number, the line number itself comes out in yellow, but the file contents are still black and white. I don't know what I did but I'd like everything to go back to what it was like before I started changing anything. I have restarted the raspberry pi and reinstalled vim using apt-get install vim --reinstall but nothing helped.

Is there a master reset method? How do I get vim to change everything back to factory default? In the home folder (~) I only have these files possibly related to vim: .viminfo (very large file and has lots of things, but looks like it's only file and command history, and not any settings), .vimrc (I had added set number to this file initially but I deleted it after my problem started happening. Currently this file is completely empty, which is how it was before). I don't see a .vim folder in ~, as some posts that result form a google search seem to indicate should be there. I am using raspberry pi OS on raspberry pi zero.

2 Answers 2


First of all, most probably you don't need to reset to "factory settings".

To see colors of the c filetype you have to either manually :set filetype=c or add to your vimrc a setting that will autodetect it.

After filetype was detected you should have :syntax on to actually turn on syntax highlighting for the detected filetypes.

Usually these lines are in vimrc:

filetype plugin indent on
syntax on

to make it happen "automatically".

Ther is also "default" settings that are turned on if you DON'T have your own vimrc. :h defaults.vim:

                            *defaults.vim* *E1187*
If Vim is started normally and no user vimrc file is found, the
$VIMRUNTIME/defaults.vim script is loaded.  This will set 'compatible' off,
switch on syntax highlighting and a few more things.  See the script for
details.  NOTE: this is done since Vim 8.0, not in Vim 7.4. (it was added in
patch 7.4.2111 to be exact).

This should work well for new Vim users.  If you create your own .vimrc, it is
recommended to add these lines somewhere near the top: >
    unlet! skip_defaults_vim
    source $VIMRUNTIME/defaults.vim
Then Vim works like before you had a .vimrc.

Meaning that if you have created one in your home directory (or ~/.vim/vimrc) and it is empty -- vim doesn't load those settings from defaults.vim and you don't have syntax highlighting and other stuff defined there.

  • I see. Thank you. It's possible there wasn't an empty .vimrc file at ~ since the beginning, I might have created it when I wanted to add :set number. I guess I should delete the .vimrc file and see what happens. Do you have any ideas on the ssh problem in my linked question?
    – user13267
    Nov 11, 2021 at 11:41

When you don't have a ~/.vimrc file nor a ~/.vim/ directory, you're with your distro defaults (or more precisely, it load the location of $VIMRUNTIME/defaults.vim file.) So be sure to remove you ~/.vimrc (even empty) to restore distro settings. If you want to avoid this one and have factory compiled only, so go echo > ~/.vimrc to have an empty one. However, I'm not sure this later is what you were looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.