2

After launching a terminal inside vim via :terminal, vim doesn't put curosr in the right position after pressing i in normal mode. As seen in the following picture, the cursor is put at the end of the line while I expected it to be placed right after "word2".

cursor not in the right position when switching from normal mode to insert mode

How can I tell vim to behave as I have expected?

1 Answer 1

2

:terminal runs another process (program). That process has its own cursor. When you enter terminal-normal mode, you control Vim's cursor, not the program's one. And after you return to terminal-insert you're again talking to that program and moving its cursor. So this is absolutely expected and works as it should.

3
  • 1
    I see. But what if I want vim to sync the launched process's cursor position with vim's cursor postion? Sometimes I need to modify a command in the terminal, so I want to jump right to the expected position after switching from terminal-normal mode to terminal-insert mode.
    – Coiby
    May 29, 2020 at 1:49
  • 1
    @Coiby You can modify picture on screen, but you can't modify process' internal state from Vim. This is nonsense. Terminal-normal is intended for yanking text into Vim, not for anything else.
    – Matt
    May 29, 2020 at 4:47
  • 1
    The background is I want to use vim' terminal to replace tmux or other terminals so copy and paste among terminals would be very easy. So I still need the help of vi mode in bash/zsh to move the 2rd cursor.
    – Coiby
    May 30, 2020 at 1:39

Your Answer

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

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