---
title: "Abbreviations in Vim"
url: "https://courses.osherove.com/courses/vim-hates-you/abbreviations-in-vim.md"
canonical: "https://courses.osherove.com/courses/vim-hates-you/abbreviations-in-vim/"
tags: []
author: "Roy Osherove"
description: "Lesson 25 of 26 in Vim Hates You (Go Faster), 2:25. 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/"
---

# Abbreviations in Vim

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

Lesson 25 of 26

Duration: 2:25 [Watch on YouTube](https://www.youtube.com/watch?v=PEPc_OOS1_8)

## In this lesson

Roy describes abbreviations as text completions on the fly: he defines one that expands my email into his email address, which could also be kept in the vimrc, and in insert mode it expands as soon as he types a character that is not alphanumeric. He suggests them for long text such as copyright notices and email signatures, or for common spelling mistakes. Unlike a mapping, an abbreviation is only expanded when it is typed outside of another word.

## Transcript

347 words

[\[00:09\]](https://www.youtube.com/watch?v=PEPc_OOS1_8&t=9s) In Vim are really yummy little snack feature kind of thing. Kind of like a little popcorn that you can put into your Vim soup and just enjoy it continuously and add to it as much as you like. And basically they're just text completions on the fly. You know, let's say that you always type your email and you don't want to write your email always. You just want to have text auto expanded to that. Well, you just type the command. Sorry, let's out get out of insert mode. Type the command IB

[\[00:40\]](https://www.youtube.com/watch?v=PEPc_OOS1_8&t=40s) Riv. I just type tab to go there. and you just say when I type my my email, I want you to expand it to roy.com. So now if I have that or if I had that in my vimrc, all I have to do is to say let's go into insert mode. My email is my email. And if I press anything that's not alpha numeric,

[\[01:11\]](https://www.youtube.com/watch?v=PEPc_OOS1_8&t=71s) It gets expanded automatically. And technically, we could always configure Vim to say on what it gets expanded on, etc. But that's the basic idea. You can just have abbreviations for things that are long like copyright or email signatures or or sometimes people use them just for common spelling mistakes uppercase lowerase mistakes. Anything really is just a really simple powerful nugget that you use. Now you might ask why wouldn't I use that instead as a u binding as a mapping and the answer is that mapping does not take does not take into account the text that you wrote before.

[\[01:54\]](https://www.youtube.com/watch?v=PEPc_OOS1_8&t=114s) So technically I could type that text my email into a mapping but then if it was inside another word then that other word would get halfway would get expanded into my text. This does not happen if I just use abbreviations because Vim is smart enough to know what came before the abbreviation, what came after, and it looks specifically for the fact that you type the abbreviation outside of a word. So that's it. Hope you enjoy this little nugget.

[Previous lesson Vim and the System Clipboard](https://courses.osherove.com/courses/vim-hates-you/vim-and-the-system-clipboard/) [Next lesson VIm Macros](https://courses.osherove.com/courses/vim-hates-you/vim-macros/)


---

## 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/
