I am editing a DocBook XML file and want to validate it by running a custom command validate_cmd. In my plugin, I'm running the following:

let term_buff_no = term_start(validate_cmd, {'term_rows': 10})

The problem is that I don't want vim to focus the newly opened terminal buffer but instead keep the editing buffer opened and continue working. How to do that?

  • What about :normal! <C-w>p?
    – husB
    Jun 22, 2022 at 14:15
  • 1
    @husB aka :wincmd p
    – D. Ben Knoble
    Jun 22, 2022 at 16:20

1 Answer 1


After the terminal buffer is opened, you can switch back to the previous window with the keys <C-w>p.

For non-interactive use (such as in a script), you may append those keystrokes with :normal! <C-w>p. Equivalently -- as Ben mentioned in the comments -- you may use :wincmd p.

FYI, from the documentation of :normal,

:norm[al][!] {commands}                 *:norm* *:normal*
            Execute Normal mode commands {commands}.  This makes
            it possible to execute Normal mode commands typed on
            the command-line.  

            If the [!] is given, mappings will not be used.

and from the documentation of :wincmd,

:[count]winc[md] {arg}
        Like executing CTRL-W [count] {arg}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.