Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When within vim (the editor I use mostly because of the terminal integration), I want to run my script (e.g. Python or Javascript) from within vim.

I do not mind if it opens a new window, I would just like to know if there is an editor command for save/run. TNX1.0E6,

share|improve this question

You can run commands inside of vim with !

:!echo "hello"

The symbol % is a shortcut for the name of the current open file, so you can execute your current file with


The console output will appear, and you press enter to return to editing your file

You can add a keybind to save and run in your ~/.vimrc

nnoremap <F5> <esc>:w<enter>:!%:p<enter>
inoremap <F5> <esc>:w<enter>:!%:p<enter>
share|improve this answer

I specifically use this to compile and view LaTeX documents in vim:

map     <F5>            :! pdflatex "%"<CR><CR>
map     <F6>            :! xdg-open "%<.pdf";<CR>

the "%<" gets the name of the current file in buffer without the extension, (i.e., when I'm editing book.tex, it returns book so I can attach my own ending.

share|improve this answer

You can set up a Makefile in your project folder and then use vim's built-in :make command. Since Makefiles are ridiculously powerful and aren't limited to compiling C applications, you can set it up to call your script and do any additional processing that is needed.

The contents of the Makefile would look like:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.