Mapping a Piped Shell Command in Vim
Posted
by michaelmichael
on Super User
See other posts from Super User
or by michaelmichael
Published on 2010-04-23T21:08:58Z
Indexed on
2010/04/23
21:13 UTC
Read the original article
Hit count: 381
In a previous question I asked about mapping evaluated code to a new window in MacVim. I got a great solution, but it presented another question: How can I map a key command in my .vimrc
that involves piping output in the shell?
As a simple example, let's say I wanted to pipe the results of ls -a
to a new MacVim window. From the Vim command line I can enter !ls -a | mvim -
, and the results will appear in a new window. Great! Now, I add that to my .vimrc
:
nmap <Leader>r :w !ls | mvim<CR>
Vim now throws an error every time I try to source my .vimrc
, which reads as follows:
E492: Not an editor command: mvim<CR>
Any ideas on how to overcome this?
© Super User or respective owner