zoukankan      html  css  js  c++  java
  • spark要我命_2_算了,不起标题了

    这篇记录的的是怎么在vim里让scala代码高亮,主要内容是一个.vimrc,需要保存在用户目录下,因为我是用hadoop用户编写scala,所以放在了hadoop用户的home里。
    这个.vimrc的内容是东拼西凑来的,对于spark来说,它最实用的地方在于能够让scala高亮,正常的vim编辑器是不能够高亮scala的。
    因为这段脚本里,给vim安装了一个插件:vim-scala
    vim-scala的github项目的网址是:https://github.com/derekwyatt/vim-scala
    另外,这个插件是用Vundle装的,所以要先装Vundle,安装方法是:

    git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
    

    简单粗暴


    下面是我的vimrc的内容,前半部分是很久之前复制来的,用来显示行号什么的东西,博客的最下面有一个精简版,就是如果只要显示scala高亮必须要在vimrc里加的内容

    "双引号开始的行为注释行,下同
    "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
    set nocompatible
    
    "显示行号( 看代码时很有必要)
    set number
    
    "检测文件的类型
    filetype off
    
    "记录历史的行数
    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
    
    au BufNewFile,BufRead *.py
     set tabstop=4 |
     set softtabstop=4 |
     set shiftwidth=4 |
     set textwidth=79 |
     set expandtab |
     set autoindent |
     set fileformat=unix
    
    "设置匹配模式
    set showmatch
    
    "去除vim的GUI版本中的toolbar
    set guioptions-=T
    
    "当vim进行编辑时,如果命令错误,会发出一个响声,该设置去掉响声
    set vb t_vb=
    
    "在编辑过程中,在右下角显示光标位置的状态行
    set ruler
    
    "默认情况下,寻找匹配是高亮度显示的,该设置关闭高亮显示
    set nohls
    
    "查询时非常方便,如要查找book单词,当输入到/b时,会自动找到第一“个b开头的单词,当输入到/bo时,会自动找到第一个bo开头的单词,依“次类推,进行查找时,使用此设置会快速找到答案,当你找要匹配的单词“时,别忘记回车
    set incsearch
    
    "修改一个文件后,自动进行备份,备份的文件名为原文件名加“~“后缀
    "if has(“vms”)   
    "	set nobackup
    "else   
    "	set backup
    "endif
    
    "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')
    Plugin 'derekwyatt/vim-scala'
    " 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
    
    "Bundle 'derekwyatt/vim-scala'
    

    其实让scala高亮,最关键的是这几句(filetype一定要off),上面的别的东西对于让scala高亮这个问题都不太重要,是用来干别的的

    filetype off
    
    set rtp+=~/.vim/bundle/Vundle.vim
    call vundle#begin()
    Plugin 'derekwyatt/vim-scala'
    

    好了,就这样,把vimrc保存好,然后冒号进入vim命令行,输入PluginInstall,安装插件
    安装好了大概是这样的

    然后scala代码就能高亮了

  • 相关阅读:
    Express入门
    nodejs入门
    css实现点点点效果
    定时器详解和应用、js加载阻塞、css加载阻塞
    栈内存和堆内存有什么区别?
    webpack入门
    Ubuntu常用命令集合
    HTTP缓存机制
    125. 验证回文字符串
    算法的时间复杂度和空间复杂度(js版)
  • 原文地址:https://www.cnblogs.com/ltl0501/p/12727969.html
Copyright © 2011-2022 走看看