After running a command that opens a new split (e.g. :botright 10new
), how can I have the cursor move back to its previous position? A use case would be to show a message in a scratch buffer without moving out of the current file.
1 Answer
Use :h :wincmd
to go to the previous window with :h CTRL-W_p
, leaving your cursor where you were before the split.
Following your example, to create a window 10 lines tall at the bottom of the tab, then return to the previous cursor position:
:botright 10new | wincmd p
-
1Easier is
wincmd p
here, since you're in command-line mode already... Commented Nov 10, 2020 at 5:17 -
1