The Vim Config file

Mike Hartington
InstructorMike Hartington
Share this video with your friends

Social Share Links

Send Tweet
Published 9 years ago
Updated 4 years ago

Now that you know how to enable features in Vim, let's store all of them in one place so we don't need to constantly set them all the time.

[00:01] In our last lesson, we looked at how we can set of Vim's options once we have the editor running. While this works, it's not ideal. If we were to quit the editor and, then, start it back up again, we'd have to go back and reset all those options all over.

[00:19] Instead, we can create a Vim config file called .vimrc and store all of our options there. This file sits in our home directory and will be run every time we start Vim. Let's quit this file and, then, start a new Vim session.

[00:36] This time, we're going to create our Vimrc file. To start off our RCFile, we'll add the original options for syntax highlighting and line numbers. Let's also enable some file type detection and some features to expand tabs into two spaces.

[01:01] Lastly, we'll enable being able to backspace over essentially anything. With these settings in place, we'll save and quit Vim, then open our sample.js file again. Now we have all these settings in place, and we didn't need to enable them one by one.

[01:23] The Vimrc file can be as minimal as the one we've just created or much more complex, loading other scripts that add more functionality to the editor.