aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-03-24 15:01:33 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-03-24 15:01:33 +1300
commitebda819bd699ebc75d3ff37561c18023e8ac0165 (patch)
tree3e1c1535a47761a22aaa330636a2eab60cde7475
parentAdd exm(1df) to work around Vim's screen-clearing (diff)
downloaddotfiles-ebda819bd699ebc75d3ff37561c18023e8ac0165.tar.gz
dotfiles-ebda819bd699ebc75d3ff37561c18023e8ac0165.zip
Better exm(1df) implementation
-rwxr-xr-xbin/exm7
-rw-r--r--man/man1/exm.1df7
2 files changed, 6 insertions, 8 deletions
diff --git a/bin/exm b/bin/exm
index cfae82d4..7f4b4de0 100755
--- a/bin/exm
+++ b/bin/exm
@@ -1,10 +1,11 @@
#!/bin/sh
-# If input is a terminal and ex(1) is the Vim version, force it to use a dumb
-# terminal so it doesn't clear the screen
+# Prevent Vim's ex(1) implementation from clearing the screen
if [ -t 0 ] ; then
ver=$(ex --version | sed '1{s/ .*//;q}') 2>/dev/null
case $ver in
- VIM) set -- -T builtin_dumb "$@" ;;
+ # Lie to Vim; tell it it's a dumb terminal, and that its required "cm"
+ # feature is invoked with a newline character.
+ VIM) set -- -T dumb -c 'exe "set t_cm=\<C-M>"' "$@" ;;
esac
fi
exec ex "$@"
diff --git a/man/man1/exm.1df b/man/man1/exm.1df
index 892ca326..7a68a031 100644
--- a/man/man1/exm.1df
+++ b/man/man1/exm.1df
@@ -11,12 +11,9 @@ works around a quirk of Vim that causes it to clear the screen when invoked as
ex(1) interactively. It applies Vim's -T option to force the terminal to the
builtin "dumb" terminal.
.SH CAVEATS
-This doesn't work on its first invocation from any given terminal, but does
-work thereafter. I haven't yet figured out why.
-.P
-This breaks switching to visual mode with :visual somewhat, as the terminal
+This breaks switching to visual mode with :visual completely, as the terminal
will persist in its dumb state. I'm not sure there's a way to fix this. If
there were a Vim :autocmd for mode switching, it might be possible, or perhaps
-by wrapping :visual somehow to :set terminal=$TERM.
+by wrapping :visual somehow to :set terminal=$TERM before the switch.
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>