
Usando :r !command
, agregue el resultado a la siguiente línea.
¿Es posible agregar la salida del comando desde el cursor en la misma línea?
Respuesta1
¿Qué tal las siguientes asignaciones para el modo de inserción y de línea de comandos?
" i_CTRL-R_` Insert the output of an external command.
" c_CTRL-R_`
function! s:QueryExternalCommand( newlineReplacement )
call inputsave()
let l:command = input('$ ', '', 'shellcmd')
call inputrestore()
return (empty(l:command) ?
\ '' :
\ substitute(substitute(system(l:command), '\n\+$', '', ''), '\n', a:newlineReplacement, 'g')
\)
endfunction
inoremap <C-r>` <C-g>u<C-r>=<SID>QueryExternalCommand('\r')<CR>
cnoremap <C-r>` <C-r>=<SID>QueryExternalCommand('\\n')<CR>