LoginSignup
9
7

More than 5 years have passed since last update.

Vim で 現在開いているファイルを簡単に実行して、結果を表示させる

Last updated at Posted at 2013-11-06

現在開いているファイルをスペースキーを押すことによって実行します。(PHP, Ruby, Go のみ)

vim-execute-c-urrent-file.gif

.vimrc
" 現在開いているファイルを実行 (only php|ruby|go)
function! ExecuteCurrentFile()
  if &filetype == 'php' || &filetype == 'ruby'
    exe '!' . &filetype . ' %'
  endif
  if &filetype == 'go'
    exe '!go run *.go'
  endif
endfunction
nnoremap <Space> :call ExecuteCurrentFile()<CR>
9
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
7