Vim config file empty

I want to permanently display line numbers so when i type:

vim ~/.vimrc

the config file is empty and it is marked as 'new'. I already tested vim it works perfectly but i don't know why the config file is empty.


Solution 1:

It's empty because you haven't put anything in it yet.

(In fact, like most other files in your home directory, it's not even "empty" when you first open it – it doesn't even exist until you create it.)

All Vim settings have a default value embedded in the actual program, and it's mostly those defaults that define how Vim works out-of-the-box. This means Vim can run without any config file at all.

(Although there is sometimes a system-wide vimrc file with distribution-specific tweaks, such as disabling the "vi compatible" mode or enabling colors by default. It's usually just a few settings.)

But ~/.vimrc, due to being located in your ~/ – your home directory – is your personal configuration file that only needs to contain customizations that you want to apply on top of those built-in default values. So even though in theory it could be automatically created for new accounts, there is no real reason for it to exist by default.

(If each new account automatically got a template config for every single app that might need one, that would be a lot of configs. Like, possibly in the hundreds. On my main Linux system, even just the various "dot"files that were automatically created by apps accumulated to the point that the 'ls -a ~' output didn't fit in the screen after a few years.)