---
title: "Vim Shortcuts in Bash and ZSH"
url: "https://courses.osherove.com/courses/vim-hates-you/vim-shortcuts-in-bash-and-zsh.md"
canonical: "https://courses.osherove.com/courses/vim-hates-you/vim-shortcuts-in-bash-and-zsh/"
tags: []
author: "Roy Osherove"
description: "Lesson 12 of 26 in Vim Hates You (Get Somewhat productive in an hour or so), 1:36. 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/"
---

# Vim Shortcuts in Bash and ZSH

1. [Courses](https://courses.osherove.com/#courses)
2. [Vim Hates You](https://courses.osherove.com/courses/vim-hates-you/)
3. Get Somewhat productive in an hour or so

Lesson 12 of 26

Duration: 1:36 [Watch on YouTube](https://www.youtube.com/watch?v=J9Yg0aetdVQ)

## In this lesson

Roy shows that Bash and Zsh can use vi key bindings to edit the command line, turned on with set -o vi, which can also go in the shell's rc file. After pressing Escape on a long command line he uses b, cw, dd, p, Shift-P and undo to move, change, delete and paste text.

## Transcript

221 words

[\[00:06\]](https://www.youtube.com/watch?v=J9Yg0aetdVQ&t=6s) One of the coolest things you can actually do with vi is to understand that its bindings appear almost everywhere. You can even have your bash or zshell in my case to use vim command vim shortcuts. So to set it you would do and this works both in bash or in zshell you would say set minus o and then vi and from this moment on and of course you can put this in your like bash rc file or zshell rc file you you can actually edit your command lines this way.

[\[00:39\]](https://www.youtube.com/watch?v=J9Yg0aetdVQ&t=39s) If this is a really long command line and I press escape, let me just show you the shortcuts here. I can actually press B to go back. I can press CW. Let's say CW to change a word here. Changed. I can press escape again. I can press DD to delete the whole line. I can press P to paste the line just above.

[\[01:11\]](https://www.youtube.com/watch?v=J9Yg0aetdVQ&t=71s) I can press undo to undo. I can press shift P to paste the line right here and etc etc. So vi is really really useful in many many places and this is just this small tip has changed my life. Well well as far as you can change your life if you're a geek like me when working with command lines.

[Previous lesson Useful Vim Commands Reference](https://courses.osherove.com/courses/vim-hates-you/useful-vim-commands-reference/) [Next lesson Multiple Windows](https://courses.osherove.com/courses/vim-hates-you/multiple-windows/)


---

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