通过Vundle工具来安装,首先得安装Vundle
一、 Vundle安装
1. Set up Vundle
$ git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
2. Configure Plugins
将以下内容放入 .vimrc 文件的开头,以下内容中不需要的plugins 可以移除掉,'' 为注释。
set nocompatible " be iMproved, required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required Plugin 'gmarik/Vundle.vim' " The following are examples of different formats supported. " Keep Plugin commands between vundle#begin/end. " plugin on GitHub repo Plugin 'tpope/vim-fugitive' " plugin from http://vim-scripts.org/vim/scripts.html Plugin 'L9' " Git plugin not hosted on GitHub Plugin 'git://git.wincent.com/command-t.git' " git repos on your local machine (i.e. when working on your own plugin) Plugin 'file:///home/gmarik/path/to/plugin' " The sparkup vim script is in a subdirectory of this repo called vim. " Pass the path to set the runtimepath properly. Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} " Avoid a name conflict with L9 Plugin 'user/L9', {'name': 'newL9'} " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on " " Brief help " :PluginList - list configured plugins " :PluginInstall(!) - install (update) plugins " :PluginSearch(!) foo - search (or refresh cache first) for foo " :PluginClean(!) - confirm (or auto-approve) removal of unused plugins " " see :h vundle for more details or wiki for FAQ " Put your non-Plugin stuff after this line二、 安装vim-scala
1. 将以下内容加入到 .vimrc中
Bundle 'derekwyatt/vim-scala'
2. 进入vim输入以下命令完成安装
:BundleInstall
到此你用vim打开.scala文件就有语法高亮了
附: .vimrc 设置方法
需要手动设置一个配置文件:.vimrc。
在启动vim时,当前用户根目录下的.vimrc文件会被自动读取,该文件可以包含一些设置甚至脚本,所以,一般情况下把.vimrc文件创建在当前用户的根目录下比较方便,即创建的命令为:
$vi ~/.vimrc
设置完后
$:x 或者 $wq
进行保存退出即可。
下面给出一个例子,其中列出了经常用到的设置,详细的设置信息请参照参考资料:
“双引号开始的行为注释行,下同
“去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
set nocompatible
“显示行号( 看代码时很有必要)
set nummber
“检测文件的类型
filetype on
“记录历史的行数
set history=1000
“背景使用黑色(Ubuntu效果下建议不要设置)
set background=dark
“语法高亮度显示(Ubuntu效果下建议不要设置,使用系统默认的高亮显示更好)
syntax on
“下面两行在进行编写代码时,在格式对起上很有用;
“第一行,vim使用自动对起,也就是把当前行的对起格式应用到下一行;
“第二行,依据上面的对起格式,智能的选择对起方式,对于类似C语言编写上很有用
set autoindent
set smartindent
“第一行设置tab键为4个空格,第二行设置当行之间交错时使用4个空格(写Python代码时方便多了,不用再猛敲空格了)
set tabstop=4
set shiftwidth=4
“设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号(好东西,免得忘记输入右括号)