1

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

: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
  • 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 '20 at 1:49
  • @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 '20 at 4:47
  • 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 '20 at 1:39

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.