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 phere, since you're in command-line mode already...filbranden– filbranden2020-11-10 05:17:29 +00:00Commented Nov 10, 2020 at 5:17 - 1@filbranden Thanks, I've edited my answer.Jake Grossman– Jake Grossman2020-11-10 05:22:54 +00:00Commented Nov 10, 2020 at 5:22