Creating ~/.vimrc disables syntax highlighting

9

3

I started using Vim as it was first installed and then decided to change the indentation behavior by adding

set tabstop=8 softtabstop=0 expandtab shiftwidth=2 smarttab

to ~/.vimrc as suggested by https://stackoverflow.com/questions/1878974/redefine-tab-as-4-spaces. However, when I do so, syntax highlighting for my Python files is disabled. I assume it is probably disabled for other languages and that other settings are not set from the default configuration, as well, but haven't tested yet.

How do I keep the rest of the default settings and only modify the above settings for indentation? (Note: I did not have a ~/.vimrc before this. I created it and added the single line above.)

Code-Guru

Posted 2016-11-29T20:21:20.357

Reputation: 191

Answers

5

Your system default vimrc no longer gets loaded when you create your own (and that's as it should be).

You also won't get filetype based indenting and other things.

The solution is to add these lines to ~/.vimrc:

filetype indent plugin on
syntax on

Heptite

Posted 2016-11-29T20:21:20.357

Reputation: 16 267

3What if I want to keep those "other things" as well? What can I do? – Code-Guru – 2016-12-03T01:41:17.417

Locate the file and add a :source command in your vimrc. – Heptite – 2016-12-03T01:42:13.947

How to locate the file ? Where can it be ? – xtof54 – 2018-10-27T07:34:40.797

1@xtof54 Without a ~/.vimrc, do :scriptnames – Heptite – 2018-10-27T14:31:45.653

0

What I found is that the vim installation didn't contain a system default vimrc at e.g. /etc/vimrc, but it did supply some settings in /etc/skel/.vimrc which resembled the default configuration, unlike what you get if you just do syntax on in an otherwise blank .vimrc, and could be copied to an existing account as a starting point.

rakslice

Posted 2016-11-29T20:21:20.357

Reputation: 2 276