4

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 1

7

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 
2
  • 1
    Easier is wincmd p here, since you're in command-line mode already... Commented Nov 10, 2020 at 5:17
  • 1
    @filbranden Thanks, I've edited my answer. Commented Nov 10, 2020 at 5:22

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.