0

I have created the following mapping in my vimrc file:

noremap <C-p> ! firefox -new-tab http://php.net/<cword><C-m>

The problem is that it proceeds to delete the line under the cursor.

How would I make this mapping work correctly?

1
  • Maybe you should rather remap K for this and only for buffers with filetype set to php. Commented Nov 2, 2011 at 15:12

2 Answers 2

2

If I understood what you're trying to do the following should work:

nmap <c-p> :!firefox  -new-tab http://php.net/<c-r>=expand('<cword>')<CR><CR>

See docs for further information.

Sign up to request clarification or add additional context in comments.

Comments

2

You are using noremap which means that it triggers:

  • in normal mode
  • in visual mode
  • in operator-pending mode.

You should use nnoremap or xnoremap instead. Also, note that ! is a shortcut for :.! in normal mode (acts on current line) and for :'<,'>! in visual mode (acts on current visually-selected lines). If you don't want that:

nnoremap <c-p> :!firefox ... 
xnoremap <c-p> :<c-u>!firefox ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.