This is a demo of how to use VIM as a lightweight IDE to run Scala scripts. We will create a script named "HelloWorld.scala" and run it under /home/godu/test for linux or e:\mydoc\scalafiles for windows.
Prerequisite
We can compile and run Scala scripts in console. This means we've already installed JRE and scala run-time files, and defined necessary enviroment variables such as JAVA_HOME and SCALA_HOME, and add $SCALA_HOME/bin to $PATH.
Create & Run Source Files
In Linux:
cd /home/godu/test
vi HelloWorld.scala
<INSERT>println("hello, world!")<ESC>
:w HelloWorld.scala
:!scala %
In Windows:
<Open gvim>
:lcd e:\mydoc\scalafiles
<INSERT>println("hello, world!")<ESC>
:w HelloWorld.scala
:!scala %
Add IDE functionality support
syntax hightlight, auto-indent, auto-complete, code insight, etc, see note "为VIM增加新的语法支持";
_vimrc settings for scala IDE
let Tlist_Ctags_Cmd="f:/Software/ctags58/ctags.exe"
let tlist_scala_settings='scala;c:Classes;t:Traits;o:Objects;m:Methods;p:Packages;C:Constants;l:Local variables;T:Types'
nnoremap <silent> <F4> :TlistToggle<CR>
nnoremap <silent> <F9> :!scala %<CR>
colo evening
imap jj <ESC>
cmap jj <ESC>
set directory=C:\Windows\Temp
set backupdir=C:\Windows\Temp
set clipboard+=unnamed
set guifont=Consolas:h13
set guioptions=
set ts=2
cd e:/mydoc/scalafiles
For more information about the usage of filename-relative shortenings, use the following command for detail.
:h filename-modifiers
Frequently Used:
:!echo % // show file name and extension
:!echo %< // show only file name
:!echo %:t:r // show only file name
:!echo %:p // show full path
:!echo %:e // show only file extension