* vim control-a at the shell
@ 1997-08-19 8:36 Matthias Kopfermann
1997-08-19 9:11 ` Andrew Main
0 siblings, 1 reply; 2+ messages in thread
From: Matthias Kopfermann @ 1997-08-19 8:36 UTC (permalink / raw)
To: zsh-users
Hi fellows!
i love that little feature within vim
if you have a number say 20 and you press control-a with vim it becomes
21 while control-x does 19.
our zsh is such a great shell that i am almost sure i can do that
at the prompt, too but how should i do it?
any clues?
btw: i really love my zsh and i miss it every time, where there is no zsh around!
--
Matthias
(this message came from Hamburg/Germany)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: vim control-a at the shell
1997-08-19 8:36 vim control-a at the shell Matthias Kopfermann
@ 1997-08-19 9:11 ` Andrew Main
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Main @ 1997-08-19 9:11 UTC (permalink / raw)
To: Matthias Kopfermann; +Cc: zsh-users
Matthias Kopfermann wrote:
>i love that little feature within vim
>if you have a number say 20 and you press control-a with vim it becomes
>21 while control-x does 19.
This is more commonly on #+ and #-.
>our zsh is such a great shell that i am almost sure i can do that
>at the prompt, too but how should i do it?
A recent zsh beta is required (3.1.2 will do):
function increment-number {
local n=${(M)LBUFFER%%[0-9]#}${(M)RBUFFER##[0-9]#}
LBUFFER=${LBUFFER%%[0-9]#}$((n+1))
RBUFFER=${RBUFFER##[0-9]#}
}
zle -N increment-number
bindkey -a '#+' increment-number # nvi binding
bindkey -a '^A' increment-number # vim binding
Similarly for decrement, but change $((n+1)) to $((n-1)) and adjust the
key bindings. nvi et al also have a ## command, which repeats the last
of #+ and #- to be invoked explicitly. To do this, add the command
last_number=increment-number
to the increment-number function, and the corresponding line to
decrement-number, and then do
function last-number {
[[ -n "$last_number" ]] && zle $last_number
}
zle -N last-number
bindkey -a '##' last-number
-zefram
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1997-08-19 9:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-08-19 8:36 vim control-a at the shell Matthias Kopfermann
1997-08-19 9:11 ` Andrew Main
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).