sponsor Vim development Vim logo Vim Book Ad

basic Tip #1504: External commands on Windows

 tip karma   Rating 82/82, Viewed by 15110 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   February 6, 2007 9:16      complexity:   basic
author:   Tim Keating      as of Vim:  

If you want to execute an external command on Windows, you need to know one trick. Let's say you're building a command to check out the file you're working on (using Perforce as an example):

map <f6>:!p4 edit %

However, that will just populate the command line. To force the command to execute without having to hit Enter, you need to embed a CR/LF. On Linux, you do this with CTRL+V CTRL+M. On Windows (as of version 7; not sure how far back this goes), CTRL+V is mapped to "Paste from Windows Clipboard". You have to use CTRL+Q instead:

map <f6>:!p4 edit %CTRL+Q CTRL+M

Which will look like:

map <f6>:!p4 edit %^M

 rate this tip  Life Changing Helpful Unfulfilling 

<< substitute last search |

Additional Notes

Anonymous, February 6, 2007 11:16
you could use <CR> (4 characters), which should work when your 'cpo' does not have < included. See
:he cpo-<
:he <>

even with < in 'cpo' you would be able to enter mapping this way - you need to use <special> modifier. See
:he :map-special

marian
Anonymous, February 6, 2007 11:21
...and one more thing:
Ctrl-V is mapped only when your _vimrc contains following line:
source $VIMRUNTIME/mswin.vim

marian
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo