Making Permanent Setting Changes in Vim with the vimrc File
This guide examines how to edit the vimrc file so that you can implement permanent settings in Vim that can be utilized throughout your system.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

In this guide, we're gonna talk about how we can set permanent setting changes inside of Vim. So as we talked about last time, if you make a setting change such as page numbers, I can type in colon and then set nu, this change is only active for the active session. So if I quit out of it, get back in, our page numbers are gone.

In order to fix this, what you can do is open up what's called your Vim RC file. You may or may not already have one, but it's perfectly fine, we can create one and that's what we're gonna do here.

My Vim RC file usually has a few hundred lines of commands and settings in it. For this course, I cleared all of those out and I also made it available in the show note so you could copy and paste all of the settings that I have, but I recommend that you play around with it and you can take the settings I have implemented because they've taken a few years to kind of polish up and then refine them based on your own work flow.

Now to make a change to that file, we're gonna open up Vim RC file. So I'm gonna type Vim and then you want to navigate to your home directory, so I'm gonna say vim tilda, slash and then this is an invisible file, so it's gonna start with a period and then it's gonna be, Vim RC.

vim ~/.vimrc

Like I said, you may or may not already have that available, but for the sake of this, let's pretend that it really doesn't matter. We're either gonna create it or we're gonna open another one up and just when I do that you can see that my Vim RC file is completely empty because I deleted it before I started filming.

large

Now let's test this out. Before we start adding in a lot of things, let's make sure that this is all wired up properly. If I type set, and then nu, I'm going to save and quit out of this just like any other file. And now let's open up vim example again and look at that, now our line numbers are there and we didn't have to make a change. I can quit out of it, open it back up, and now those items are permanent.

large

So that is how you can create permanent setting changes with your vimrc file and to review the way you can navigate to that is vim ~/.vimrc and you will have access to be able to make any and all changes to this file.

So now that we have that, in the next guide, I'm going to walk through some very common settings and I'm gonna show you the base settings that I'd recommend that you have inside of your own Vim RC file and I'm going to put those in there. So for the rest of the course, we're gonna have some nice shortcuts and some nice settings that we can build on.