summary refs log tree commit diff
path: root/Functions/Zle/move-line-in-buffer
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2011-06-01 15:30:20 +0000
committerBart Schaefer <barts@users.sourceforge.net>2011-06-01 15:30:20 +0000
commit0cc65dba531a792db26592a4e9c1efe5f9f667bd (patch)
tree1ad820c23975f5ce55662bd6c27caee46fdb750b /Functions/Zle/move-line-in-buffer
parentf1667d2c62ebd47b0e8bd48b2c64912b733066eb (diff)
downloadzsh-0cc65dba531a792db26592a4e9c1efe5f9f667bd.tar.gz
zsh-0cc65dba531a792db26592a4e9c1efe5f9f667bd.tar.xz
zsh-0cc65dba531a792db26592a4e9c1efe5f9f667bd.zip
users/16064: example widget for line motion inside multiline buffers
without navigating history
Diffstat (limited to 'Functions/Zle/move-line-in-buffer')
-rw-r--r--Functions/Zle/move-line-in-buffer16
1 files changed, 16 insertions, 0 deletions
diff --git a/Functions/Zle/move-line-in-buffer b/Functions/Zle/move-line-in-buffer
new file mode 100644
index 000000000..1a0efd9ca
--- /dev/null
+++ b/Functions/Zle/move-line-in-buffer
@@ -0,0 +1,16 @@
+#autoload
+
+# Line motions that do not leave the current history entry,
+# for editing in multi-line buffers.
+
+# To use:
+#  autoload -Uz move-line-in-buffer
+#  zle -N up-line-in-buffer move-line-in-buffer
+#  zle -N down-line-in-buffer move-line-in-buffer
+#
+# then bindkey as you prefer
+
+local hno=$HISTNO curs=$CURSOR
+zle .${WIDGET:s/in-buffer/or-history} "$@" &&
+    (( HISTNO != hno && (HISTNO=hno, CURSOR=curs) ))
+return 0