TIL: pedit

Often times I find myself editing a file and I suddenly realize I need to look up some data from some other file. Until today, I would normally do something along the lines of the following:

  • :sp path/to/file
  • <C-w><C-w>

I continue editing my original file. When I find I no longer need the reference file, I need to switch to it and kill its window:

  • <C-w><C-w>
  • :q

There is a better way. pedit path/to/file (or :ped if you’re lazy like me) will open a split window just as before, but cuts out the middle commands. Focus stays on the file I was working on with my cursor unmoved. The same scenario with :pedit is:

  • :ped /path/to/file
  • (continue editing my buffer)
  • :pc

Four steps cut to two. This is why I use vim.

blog comments powered by Disqus