2

If I press v while using either the vi-mode zsh plugin or set -o vi in bash, it opens the line I'm working on in a full vim session. However, this puts my cursor at the beginning at the beginning of the line. Is it possible to keep my cursor where I invoked the v command? I would like this for doing quick text manipulation that isn't possible with the basic command-line mode.

I'm referring specifically to the vi-mode zsh implementation, but a bash solution would be welcome too.

  • 1
    this should work already, if EDITOR=vim – Mass Mar 27 at 20:26
  • 1
    For bash you could set VISUAL to a script that first determines the column and then starts vim with vim "+call cursor(1, $column)" "$@". So Vim is not the problem, the problem is how to determine the cursor position. This is a question that might be better ask in a community with bash experts. – Ralf Mar 27 at 22:33
  • @Mass I don't think so – Max Coplan Mar 29 at 13:46
  • look at the file /usr/share/zsh/functions/Zle/edit-command-line, it should contain the comment Open the editor, placing the cursor at the right place if we know how. and code to do so. If you don't have that, possibly your zsh is older. – Mass Mar 29 at 14:04

Your Answer

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

Browse other questions tagged or ask your own question.