Today I learned: How to suspend Vim temporarily, run some commands, and go back
Posted on
Two magic commands
- In Vim,
CTRL + z
suspends it, putting its process in the background. You land back, in your Terminal, where you launch thevim
process. - In the terminal,
fg
puts back the background process in the foreground.
A use case out of so many
- You are coding in Vim
- You want to quickly lint your all code base to capture lint issues
CTRL + z
to go back to the Terminal- Run your lint command, in my case:
npm run lint
- Run
fg
to jump back where you left your Vim
Although I am using TMUX and could have a dedicated split or window for the lint purpose I could switch to, I found that presented solution requires less brain power.
References
"How to temporarily exit Vim and go back" Stack overflow thread