Tuesday, February 4, 2014

Screen + Vim + Scala (with dynamic compilation of sources)

What we will have at the end of this post:

Step 1. Vim installation and configuration

$ sudo yum install vim

Create ~/.vimrc file with the following content:

set nocompatible "Not vi compatible
syntax on "Turn on syntax highlighting
set showmatch "Highlight matching braces

colorscheme delek

filetype indent on
filetype on
set autoindent "Copy indent from the row above
set si "Smart indent

set nu "Number lines
set hls "Highlight search
set lbr "Line break

"Use 2 space instead of tab during format
set expandtab
set shiftwidth=2
set softtabstop=2


Step 2. Adding Scala support into Vim

Just copy ftdetect, indent and syntax folders from here into ~/.vim to support Scala syntax.

Step 3. Screen installation and configuration

$ sudo yum install screen
$ screen

Split horizontally: Ctrl a then S
Switch from the first view to the second one: Ctrl a then Tab
Start a new session: Ctrl a then c
Switch back into the first view and resize it vertically: Ctrl a then :resize -v 35

Consider we have theCoolestProject folder somewhere in our workspace with .scala files inside. And we have already configured our screen, so it has two empty views. Let's do the following steps to reproduce the result represented in the picture above:

# screen view 1
$ cd ~/theCoolestProject
$ vim SomeCoolClass.scala

# screen view 2
$ cd ~/theCoolestProject
$ sbt ~compile

sbt ~compile will automatically compile .scala files after we make some changes and saving them.

Other useful screen's commands:

Ctrl a then | - to split vertically
Ctrl a then Q - to unsplit
Ctrl a then space - to switch into the next view
Ctrl a then backspace - to switch into the previous view
Ctrl a then a - to switch between a current view and the last one you opened

More information about screen is here

No comments:

Post a Comment