1 May 2003 04:39
Re: Output/Input is not to/from a terminal
Andrew Pimlott <vim-dev <at> andrew.pimlott.net>
2003-05-01 02:39:53 GMT
2003-05-01 02:39:53 GMT
On Wed, Apr 30, 2003 at 02:11:59PM +0100, Walter Briscoe wrote:
> :help todo contains
> 7 Allow using Vim in a pipe: "ls | vim -u xxx.vim - | yyy". Only needs
> implementing ":w" to stdout in the buffer that was read from stdin.
I had no idea this was a todo, and I didn't look at your
implementation, but I've done this. I use a wrapper script to map
some file descriptors, and a vim script to write the stdin buffer
when it's unloaded. It's a quick hack, but do you see any problem
with it is principle?
I made :bunload, not :w, write the buffer to stdout, since my
intuition is that you're only "happy" with the buffer when you close
it. Plus, I :w habitually, and wouldn't want this to write to
stdout. What would happen if you :w twice?
vif:
#!/bin/sh
OPTS=$(getopt -o xg -n vif --long xterm,gui -- "$ <at> ")
eval set -- "$OPTS"
VIM='vim --cmd "runtime filter.vim"'
CMD="$VIM -"
while true; do
case $1 in
-x|--xterm) CMD="xterm -e sh -c '$VIM - <&4' 4<&0"; shift ;;
-g|--gui) CMD="$VIM -g -"; shift ;;
(Continue reading)
Try <Ctrl-V><kPlus> in xterm at the prompt and see what you get.
Also try it with num-lock set.
I've heavily customised my XTerm defaults file to ensure I get
different key-sequences for nearly every key with every modifier for
this very purpose, so I've no idea what the defaults are!
E.g., in your fav. xdefaults file (pref. $XAPPLRESDIR/XTerm), the
following[snipped from mine - makes the KP keys work 'normally' with
num-lock on, and vim-mapping-friendly without]. I'm not certain <kPlus>
will work - depends what escape sequence vim thinks that is. You might
be able to tweak the defs. below to match, or else just map
<esc>whatever instead. The mappings below are what I figured were the
correct ones by examining xterm source (!) & VT manuals.
XTerm*VT100.Translations: #override \
<at> Num_Lock<Key>KP_Add: string("+") \n\
<at> Num_Lock<Key>KP_Subtract:string("-") \n\
<at> Num_Lock<Key>KP_Decimal: string(".") \n\
<at> Num_Lock<Key>KP_Divide: string("/") \n\
RSS Feed