Scala開發環境選型(2): vim + NERDTree + scala-dist + tmux
背景介紹
在之前那篇Scala開發環境選型裏,使用的是Sublime和一個Ensime插件,拋棄了IDE。嚐試了一段時間覺得在沒有IDE的情況下也蠻習慣的,所以接下來轉移到服務器上,在vim環境編碼。還是延續sublime+sbt的思路,在vim下選擇了一個樹狀結構的插件NERDTree,用scala-dist進行scala的語法高亮,最後采用tmux進行分屏,讓sbt的~compile、run和console能和vim共存在一個屏幕上,並且可以打開dstat,對cpu,內存等進行實時的監控。搭建起來之後的界麵如下圖。由於我的centos和SecureCRT可能存在一些編碼問題,分界線會有些不對稱。左側是vim自己的分屏,右側+左側vim是使用tmux對整個連接session的多屏處理。
Scala-dist
使用scala-dist在vim內對scala實現語法高亮,在~/.vim下創建幾個目錄,將相關.vim文件放置在目錄內。執行以下命令即可:
mkdir -p ~/.vim/{ftdetect,indent,syntax} && for d in ftdetect indent syntax ; do curl -o ~/.vim/$d/scala.vim https://raw.github.com/scala/scala-dist/master/tool-support/src/vim/$d/scala.vim; done
NERDTree
NERDTree是vim最流行的插件之一,下載包並將相關文件夾和文件放置到~/.vim下即可。在~/.vimrc內加入
nnoremap <silent> <F5> :NERDTree<CR>可以在vim下輸入F5就打開NERDTree。o 為 打開目錄/打開文件,i 為在新tab打開文件,P 為 回到根目錄,? 為查看NERDTree的所有快捷鍵。使用
:set mouse=a還可以支持鼠標點擊選擇目錄的功能
tmux
tmux網上資料很多,在centos上安裝的話要先安裝
yum install libevent-devel ncurses-devel
tmux屏幕之間的切換會比較類似vim,所以有人會把tmux的ctrl+b快捷鍵設置為ctrl+w,我的配置裏設置的是ctrl+a
下麵是我的~/.tmux.conf的配置,從配置中可以看到tmux常用的操作
#-- base settings --# set -g default-terminal "screen-256color" set -g display-time 3000 set -g escape-time 0 set -g history-limit 65535 set -g base-index 1 set -g pane-base-index 1 # enable mouse-select set -g mode-mouse on set -g mouse-select-pane on set -g mouse-resize-pane on set -g mouse-select-window on #-- bindkeys --# # prefix key (Ctrl+a) set -g prefix ^a unbind ^b bind a send-prefix # split window unbind '"' bind - splitw -v # vertical split (prefix -) unbind % bind | splitw -h # horizontal split (prefix |) # select pane bind k selectp -U # above (prefix k) bind j selectp -D # below (prefix j) bind h selectp -L # left (prefix h) bind l selectp -R # right (prefix l) # resize pane bind -r ^k resizep -U 10 # upward (prefix Ctrl+k) bind -r ^j resizep -D 10 # downward (prefix Ctrl+j) bind -r ^h resizep -L 10 # to the left (prefix Ctrl+h) bind -r ^l resizep -R 10 # to the right (prefix Ctrl+l) # swap pane bind ^u swapp -U # swap with the previous pane (prefix Ctrl+u) bind ^d swapp -D # swap with the next pane (prefix Ctrl+d) # misc bind e lastp # select the last pane (prefix e) bind ^e last # select the last window (prefix Ctrl+e) bind q killp # kill pane (prefix q) bind ^q killw # kill window (prefix Ctrl+q) # copy mode bind Escape copy-mode # enter copy mode (prefix Escape) bind ^p pasteb # paste buffer (prefix Ctrl+p) bind -t vi-copy v begin-selection # select (v) bind -t vi-copy y copy-selection # copy (y) # app bind ! splitw htop # htop (prefix !) bind m command-prompt "splitw 'exec man %%'" # man (prefix m) bind @ command-prompt "splitw 'exec perldoc -t -f %%'" # perl func (prefix @) bind * command-prompt "splitw 'exec perldoc -t -v %%'" # perl var (prefix *) bind % command-prompt "splitw 'exec perldoc -t %%'" # perl doc (prefix %) bind / command-prompt "splitw 'exec ri %%'" # ruby doc (prefix /) # reload config (prefix r) bind r source ~/.tmux.conf \; display "Configuration reloaded!" #-- statusbar --# set -g status-utf8 on set -g status-interval 1 set -g status-keys vi setw -g mode-keys vi setw -g automatic-rename off #-- colorscheme --# # see also: https://github.com/daethorian/conf-tmux/blob/master/colors/zenburn.conf # modes setw -g clock-mode-colour colour223 setw -g mode-attr bold setw -g mode-fg grey #colour223 setw -g mode-bg grey #colour235 # panes set -g pane-border-bg green set -g pane-border-fg green set -g pane-active-border-bg green set -g pane-active-border-fg green # statusbar set -g status-justify centre set -g status-bg grey set -g status-fg grey set -g status-attr dim set -g status-left "#[default]>> #[fg=colour187]#S #[default] #[fg-colour187]w#I.p#P#[default]" set -g status-left-attr bright set -g status-left-length 20 set -g status-right "#[fg=colour174]#(/home/work/local) #[default] #[fg=colour174]#(cut -d ' ' -f 1-3 /proc/loadavg)" set -g status-right-attr bright set -g status-right-length 80 setw -g window-status-current-fg colour223 setw -g window-status-current-bg colour237 setw -g window-status-current-attr bold setw -g window-status-current-format "#I:#W#F" #setw -g window-status-alert-attr bold #setw -g window-status-alert-fg colour255 #setw -g window-status-alert-bg colour160 # messages set -g message-attr bold set -g message-fg colour223 set -g message-bg bold
(全文完)
最後更新:2017-04-03 14:54:35