The useful command
:r!date
is not so useful in gVim for Windows (not Cygwin’s gVim) because Windows has its own date function which does not do what I want.
So, something like
:r!c:\cygwin\bin\date
would be great. But that’s a lot to type. And considering that I might want to call a few things this way, it would be nice to write a function, which I could pass an argument foo and it would run
:r!c:\cygwin\bin\foo
What’s the best way to do this? It should be:
- Permanent: stored in
.vimrcor some startup file. - Executed with as few keystrokes as possible.
Any suggestions for good places to create mappings are appreciated.
Thanks!
I think, a simpler solution for day-to-day use (especially if you are
interested in only one of the many system-like commands) would be
creating a custom synonym-command:
This tells Vim to create a new command named
RRthat accepts a rangeand one (mandatory) argument. The command just passes arguments to
read!prependingc:\cygwin\bin\to the argument.You could even provide a file completion for the files in
c:\cygwin\bin\directory. All you need for that to work is to create completion-list
function like this:
and then specify the name of that function when creating the command: