about summary refs log tree commit diff
path: root/Functions/Zle
diff options
context:
space:
mode:
Diffstat (limited to 'Functions/Zle')
-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