---
title: "Edit and source your .Vimrc faster"
url: "https://courses.osherove.com/courses/vim-hates-you/edit-and-source-your-vimrc-faster.md"
canonical: "https://courses.osherove.com/courses/vim-hates-you/edit-and-source-your-vimrc-faster/"
tags: []
author: "Roy Osherove"
description: "Lesson 22 of 26 in Vim Hates You (Go Faster), 4:54. Free video by Roy Osherove."
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Edit and source your .Vimrc faster

1. [Courses](https://courses.osherove.com/#courses)
2. [Vim Hates You](https://courses.osherove.com/courses/vim-hates-you/)
3. Go Faster

Lesson 22 of 26

Duration: 4:54 [Watch on YouTube](https://www.youtube.com/watch?v=E7WjGRnR0pk)

## In this lesson

Roy creates two leader mappings to make changing the vimrc faster: leader ev opens the vimrc in a vertical split through a special variable that always points to the vimrc file, and leader wq writes and quits it and then sources it. He tests them by adding a mapping that opens NERDTree when the leader is pressed twice. He also shows that a mapping removed from the vimrc stays in memory until Vim is restarted.

## Transcript

644 words

[\[00:07\]](https://www.youtube.com/watch?v=E7WjGRnR0pk&t=7s) It's become faster changing and sourcing our vimrc file so that we have less pain to keep changing it continuously as we work through things. I'm going to type commande and then my vimrc which is a special variable that always points to the correct vimrc file. And here if you remember we have a map leader which is our comma and I'm going to do a new mapping to open the vimrc file in a split and then I'm going to create another mapping to

[\[00:39\]](https://www.youtube.com/watch?v=E7WjGRnR0pk&t=39s) Save the vimrc file and source it. So one mapping mapping one will open the vimrc file in a new split. mapping two will write and quit it and then source it. So these are the two mappings I want to create. So let's do that.

[\[01:10\]](https://www.youtube.com/watch?v=E7WjGRnR0pk&t=70s) And norm map. So normal mode, no not recursive map. When you press leader and for me I'm going to type EV for edit vimrc file. I want that to map to a vsplit, sorry, vsplit and my vimrc variable and of course pressing enter at the end. And the second one, I'm going to copy this line and paste it right here and say leader.

[\[01:46\]](https://www.youtube.com/watch?v=E7WjGRnR0pk&t=106s) Let's change it to right quit is basically not going to be a regular right quit. I'm going to type like comma wq and that will do the following. It will write quit, which is what I want, but then it's going to press enter, of course. And then it's going to say command

[\[02:17\]](https://www.youtube.com/watch?v=E7WjGRnR0pk&t=137s) Source. Sorry, I have to do like a right quit here now that I forgot this. So, we're going to type right quit and press enter. Then, we're source my vimrc and press enter. So that's it. Now hopefully what's going to happen that if I'm going to I'm going to close this just once and I'm going to open Vim again. Now let's see what happens when I press leader EV. Leader EV and we have the split.

[\[02:48\]](https://www.youtube.com/watch?v=E7WjGRnR0pk&t=168s) So let's change it. Let's add something here. Let's add a new mapping that will that we'll know definitely works. So, let's map a new leader to NERDTree. I want NERDTree to appear when I press leader twice. So, I'm going to copy this line and I'm going to add another one another shortcut leader leader and delete word delete word delete word and repeat with dot

[\[03:22\]](https://www.youtube.com/watch?v=E7WjGRnR0pk&t=202s) And I want that to map to NERDTreeToggle as well because today if I press leader leader nothing happens. I have to press controlN but with this line active I should be able to see NERDTree just by pressing leader leader twice leader twice so let's save this again with our new shortcut which is this one leader write quit so leader WQ and I don't know if you've noticed but right at the bottom here we had a source of MRC that happened so let's see if that actually works I'm going to type leader leader and there we have our NERDTreeToggle.

[\[04:01\]](https://www.youtube.com/watch?v=E7WjGRnR0pk&t=241s) Let's do that again. Let's try to open our vimrc leader EV. And now we can let's say delete this. Delete this line and leader right quit. And we had let's see if that works any that still works. Now the reason that still works is because the old bindings have not been removed just because they were removed from vimrc. They're still in memory. But if I close Vim again, sorry, I'm going to just quit because there's nothing to write and I open Vim again, the mapping doesn't work.

[\[04:37\]](https://www.youtube.com/watch?v=E7WjGRnR0pk&t=277s) And technically, I could just say unmap, but I don't want to do that in my vimrc file if I don't have to. So that's one way you can get really more productive and much faster by editing your Vimrc file with special commands. Command leader EV leader right quit for example.

[Previous lesson Mapping Leaders in Vim](https://courses.osherove.com/courses/vim-hates-you/mapping-leaders-in-vim/) [Next lesson Understanding Vim Registers](https://courses.osherove.com/courses/vim-hates-you/understanding-vim-registers/)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
