Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: vi-mode zle: how to delete past the start char of insert mode (like VIM 'backspace'=start option)



On Sep 27,  4:03pm, Anton Sharonov wrote:
}
} After I type some text, leave insert mode, and enter it again,
} and try to delete the text I entered [...]
} I got cursor only till the point, where insert mode is started

By way of explanation, zsh is faithfully emulating traditional "vi"
behavior in this instance.  (If there's anyone familiar enough with
both vi and vim to enumerate the differences, we might be able to
put together a sample zshrc for vim emulation.)

} Desired behaviour: <C-W>, <BS>, <C-U> should remove the WORD,
} symbol, to the begin of line, respectively. (In VIM the
} corresponding option is 'backspace', value "start" controls this
} behaviour)
} 
} How can I tell zshzle that I like to be able to delete past the
} point of _start_ of the insert mode ?

You can mostly get this by replacing the corresponding key bindings
with the emacs-mode equivalents.  For example:

bindkey -v
bindkey "^W" backward-kill-word    # vi-backward-kill-word
bindkey "^H" backward-delete-char  # vi-backward-delete-char
bindkey "^U" kill-line             # vi-kill-line
bindkey "^?" backward-delete-char  # vi-backward-delete-char

These may not work precisely as you desire when you are editing a
multi-line buffer, but should be OK for most uses.  You may need to
fiddle with the value of the WORDCHARS variable to get vim-like
word motions out of backward-kill-word, or consider looking at the
select-word-style function and delete-whole-word-match (look in the
User Contributions section of the manual, under ZLE Functions).



Messages sorted by: Reverse Date, Date, Thread, Author