Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

According to the vim documentation, the :silent command can be used to avoid the hit-enter prompt.

The problem is that I want to silent a command that accepts a range as input, and this does not work because the range is passed to :silent instead of to the command itself.


To open the urls in the current file or selection, I use the following mapping in my .vimrc:

noremap <leader>u :w !urlview<cr>

where :w !urlview pipes the current file or selection to urlview standard input.

Now, trying to avoid the hit-enter prompt, I added:

noremap <leader>u :silent w !urlview<cr>

that, when invoked with a selection, rightfully responds with:

E481: No range allowed

Any clues on how to circumvent this issue?

share|improve this question
up vote 5 down vote accepted

You can modify the mapping to insert the :silent after the initial typing of the :w command, just like you would probably do when typing this interactively:

:noremap <leader>u :w<Home>silent <End> !urlview<CR>
share|improve this answer
Thanks! Since I never saw a range used "in the middle" of a command, I assumed it was not possible :|. – mrucci Apr 21 '13 at 16:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .