Today I learned: How to suspend Vim temporarily, run some commands, and go back
Two magic commands
- In Vim,
CTRL + zsuspends it, putting its process in the background. You land back, in your Terminal, where you launch the
- In the terminal,
fgputs 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 + zto go back to the Terminal
- Run your lint command, in my case:
npm run lint
fgto 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.
"How to temporarily exit Vim and go back" Stack overflow thread