Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    The Vim Config file

    Mike HartingtonMike Hartington

    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.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    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.

    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.

    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.

    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.

    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.