Reputation: 59313
I want the key combination <C-X>
to run the command :! python application.py
. From all my understanding of mapping, I tried the following: :map <C-X> :! python application.py
which almost works. It just opens the command line and types the command in, but I still have to press return for the command to launch.
Is there any way I can get it to run the command as well?
Upvotes: 1
Views: 201
Reputation:
Don't forget you can escape any key sequence with CtrlV (in Insert mode). So another way of getting the keycode for "Return" is CtrlVEnter. It will come out looking like ^M
.
Upvotes: 0
Reputation: 59313
I found an answer in an unrelated post while doing my last searches before posting the question. It seems that putting <CR>
behind the command executes it, making this do what I wanted:
:map <C-X> :! python application.py<CR>
According to the comments (thanks to melpomene) <CR>
means "carriage return", which in effect means "press enter" and is just what I needed in this case.
Slightly related, I also found out that :!!
repeats the last shell command executed, making my map somewhat superfluous.
Upvotes: 2