0

I'm now using Vim 8 and its new feature: :term.

Well, it's great but I don't know how to move the cursor out of the terminal without the mouse.

In Vim 7, we can type <C-w><C-h>, <C-w><C-l> etc to move the cursor quickly, but now when the cursor has been in the terminal, it doesn't seem there is some good way to move the cursor quickly...

  • 1
    Are you sure that's the case? I have no problems using the <C-w> keys on the terminal, even on terminal insert mode... Do you maybe have any mappings that you rely on that are not working in the terminal? – filbranden Mar 18 at 10:56
1

See :h Terminal-mode:

Terminal-Job and Terminal-Normal mode 
                                                Terminal-mode Terminal-Job
When the job is running the contents of the terminal is under control of the
job.  That includes the cursor position.  Typed keys are sent to the job.
The terminal contents can change at any time.  This is called Terminal-Job
mode.

Use CTRL-W N (or 'termwinkey' N) to switch to Terminal-Normal mode.  Now the
contents of the terminal window is under control of Vim, the job output is
suspended.  CTRL-\ CTRL-N does the same.

[...]

                                                Terminal-Normal E946
In Terminal-Normal mode you can move the cursor around with the usual Vim
commands, Visually mark text, yank text, etc.  But you cannot change the
contents of the buffer.  The commands that would start insert mode, such as
'i' and 'a', return to Terminal-Job mode.  The window will be updated to show
the contents of the terminal. :startinsert is ineffective.

So, you can do <C-w>N, then <C-w><C-h> etc.

Or, though it isn't mentioned in the quoted section, <C-w><C-w> cycles through windows even when started from Terminal mode.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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