Today I learned: How to suspend Vim temporarily, run some commands, and go back

Two magic commands

  • In Vim, CTRL + z suspends it, putting its process in the background. You land back, in your Terminal, where you launch the vim process.
  • In the terminal, fg puts back the background process in the foreground.

A use case out of so many

  1. You are coding in Vim
  2. You want to quickly lint your all code base to capture lint issues
  3. CTRL + z to go back to the Terminal
  4. Run your lint command, in my case: npm run lint
  5. 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