
Usando :r !command
, anexe a saída à próxima linha.
É possível anexar a saída do comando do cursor na mesma linha?
Responder1
Que tal os seguintes mapeamentos para modo de inserção e linha de comando:
" 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>