Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a previous question I asked about outputting 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?

share|improve this question
up vote 6 down vote accepted

Try putting this in your ~/.vimrc file:

nmap <Leader>r :w !ls <bar> mvim -<CR>


nmap <Leader>r :w !ls \| mvim -<CR>
share|improve this answer
awesome. i had tried escaping with \| to no avail. i didn't know you could use <bar>. thanks! – michaelmichael Apr 23 '10 at 23:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.