
를 사용하여 :r !command
출력을 다음 줄에 추가합니다.
같은 줄에 커서의 명령 출력을 추가할 수 있습니까?
답변1
삽입 및 명령줄 모드에 대한 다음 매핑은 어떻습니까?
" 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>