Last active
July 30, 2020 11:07
-
-
Save miles-d/2adb022dcc84890723035640f9187379 to your computer and use it in GitHub Desktop.
Insert result of external command in vim while in insert mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Prompt for input, execute, and trim newlines from the result. | |
function! ExternalCommandResult() | |
return system(input('Command: '))[:-2] | |
endfunction | |
" Create a mapping in insert mode. | |
inoremap <C-R>! <C-R>=ExternalCommandResult()<cr> | |
" Try it out with e.g. `date`: (be in insert mode) CTRL-R ! date ENTER | |
" If you like it, copy it to your .vimrc. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment