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)
- X-seq: zsh-users 14437
- From: Anton Sharonov <anton.sharonov@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: vi-mode zle: how to delete past the start char of insert mode (like VIM 'backspace'=start option)
- Date: Sun, 27 Sep 2009 22:07:30 +0200
- Cc: zsh-users@xxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=nxlFZeYgLA6Fbe5hzwjX06jClrPL6veJPFN8QpFNbAM=; b=tIWEx0Hf0mLpoTUfqTYRvRDKPrs/p5lLHpmAcETEGftbqJpApZ/utX9vR8e5U56Rva uPVciifZ9oFHOpA6AOOvfOusCg6l1nEtuE3LcOoN4LX2lUcR78ru/3/gqn6GdGs7w7G6 FWTHVrsJxuKwUBaN/L8CCuXwP2HZgGG7qcxH4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=BcTV1rzb+TxGuEyHyWEvPt4ziH1fwpC2fR7dqpYUk0f3o91/7iyEVSMpPSQCTgngBz cdNxGkpz4X9U5usIBrlNuaEsmycPspIGN9WQRz39PEu2/6rsYABjcRghQnIKIke9Xt7I clOcWrDRBBxSW7itvE0LQ/Fj258k2K8vRVQjA=
- In-reply-to: <090927104112.ZM5501@xxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <ef9dd2250909270703v7d7dfd45hfdf3e9750afa020f@xxxxxxxxxxxxxx> <090927104112.ZM5501@xxxxxxxxxxxxxxxxxxxxxx>
On 27/09/2009, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> 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.)
Nice idea !
(Strictly speaking, that is probably not the best way to provide
just one single "VIM emulation zshrc". Vim tries to stay vi
compatible, it just adds a huge amount of options, which changes
"original vi" behaviour in all directions - I believe one will
find a lot of vim users, who still uses pretty much vi-compatible
setup, just out of habit or whatever. Therefore ideally sample
zshrc should contain kind of dictionary with examples of "the zsh
ways to emulate/tune of vim most popular options: 'backspace',
'iskeyword', ...").
> } 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
Thanks, suggested mappings are working fine for me. (With one
minor exception - I should use of backward-kill-line instead of
just kill-line).
> 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).
Its happens that the backward-kill-word by default acts in the
same way as one see ^W works in bash - this behaviour is fully
satisfactory for me at the moment. Out of curiosity I have
however played a bit with WORDCHARS value.
Thanks a lot for your help !
--
Anton
Messages sorted by:
Reverse Date,
Date,
Thread,
Author