Edit and execute a command on the unix command line from vim

John John (304)

Sometimes I type or paste a lot of text on the command line and there is a small error right in the middle. Sometimes I've run a command but I need to run it again but replace a word multiple times. There are a number of ways to quickly solve this issue, but since I'm handy with vim I choose to edit the command in vim and execute it.


Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.

ctrl + x, e
While holding the control key, hit 'x' and then 'e'. This will bring up the current command in your default text editor.

John John (304)
2 minutes

Vim is a powerful tool. I often paste raw data into Vim in order to format it in a specific way, and sometimes I need to clean up the file by removing many blank lines.