이 vim wikia 항목에 따라 새 버퍼 스크립트에 대한 쉘 실행을 만든 다음 노드를 사용하여 코드를 실행하도록 확장 할 수 있습니다.
command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
function! s:RunShellCommand(cmdline)
let isfirst = 1
let words = []
for word in split(a:cmdline)
if isfirst
let isfirst = 0 " don't change first word (shell command)
else
if word[0] =~ '\v[%#<]'
let word = expand(word)
endif
let word = shellescape(word, 1)
endif
call add(words, word)
endfor
let expanded_cmdline = join(words)
botright new
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
call setline(1, 'You entered: ' . a:cmdline)
call setline(2, 'Expanded to: ' . expanded_cmdline)
call append(line('$'), substitute(getline(2), '.', '=', 'g'))
silent execute '$read !'. expanded_cmdline
1
endfunction
command! -complete=file -nargs=* RunJS call s:RunShellCommand('node '.<q-args>)
그런 다음 실행 :RunJS %
하면 node.js 실행 출력으로 새 버퍼를 가져와야합니다. 선택적으로 다음을 사용하여 사물을 직접 호출 할 수 있습니다.:Shell <cmd>
:!node %
.node
현재 파일 이름을 인수로 전달하여 외부 프로그램으로 셸됩니다 . 화면에 출력이 표시되고 Enter를 눌러 닫을 수 있습니다.