Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Maps are helpful here. I know nothing about scala, but e.g. the command </p> <blockquote> <p>:nmap &lt;F6> :!echo test&lt;CR></p> </blockquote> <p>Will call the shell command <code>echo test</code> whenever you hit F6 in normal mode</p> <p>I'm sure you can adapt it to your needs. Put in .vimrc if you want it permanent (which you probably do). More info can be found here, if you're into the whole editor scripting thing: <a href="http://www.ibm.com/developerworks/linux/library/l-vim-script-1/index.html" rel="nofollow">http://www.ibm.com/developerworks/linux/library/l-vim-script-1/index.html</a></p> <p>P.S. Forgot to mention that the <code>%</code> character expands to the current file in a shell command. You probably want something like <code>:! scala %&lt;CR&gt;</code></p> <hr> <p><strong>EDIT</strong>:</p> <p>This is a more complicated problem than I thought at first glance (I'm used to working with interpreted languages, where compile-run is a single command). Anyway, if you really still want single key compile and run functionality, try this quick script (stick it somewhere in your <code>.vimrc</code> file and restart vim):</p> <pre><code>function! CompileAndRunScala() w "save current file let l:compiler_output = system('scalac ' . expand('%:p')) " Runs scalac on current filename (absolute path) if v:shell_error "Gets last shell error code (0 means okay, anything else is error) echo 'Compile errors!' echo l:compiler_output else echo system('scala ' . expand('%:r')) " Runs scala on current file name with extension stripped (also absolute path) endif endfunction nmap &lt;F6&gt; :call CompileAndRunScala()&lt;CR&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload