Vim配置、插件和使用

一、简单配置

输入命令:

sudo vim /etc/vim/vimrc

在.vimrc文件中输入如下文本:
set tabstop=4 #Tabstop:表示一个 tab 显示出来是多少个空格的长度,默认 8。
set softtabstop=4 #Softtabstop:表示在编辑模式的时候按退格键的时候退回缩进的长度,当使用 expandtab 时特别有用。
set shiftwidth=4 #Shiftwidth:表示每一级缩进的长度,一般设置成跟 softtabstop 一样。 当设置成 expandtab 时,缩进用空格来表示
set noexpandtab #noexpandtab 则是用制表符表示一个缩进。
set nu #nu:表示显示行号。
set autoindent #Autoindent:表示自动缩进。
set cindent #Cindent:是特别针对C语言自动缩进。

配置

如果你需要配置vim,只需在Home目录创建一个~/.vimrc文件即可以配置vim了,下面将介绍安装vim插件。

二、插件

简单方法一:

只需一条命令即可

curl -sSL https://raw.github.com/ma6174/vim/master/setup.sh | sh

复杂方法二:

插件管理工具vunble

vundle是vim的插件管理工具,它能够搜索、安装、更新和移除vim插件,再也不需要手动管理vim插件。
在Home目录创建~/.vim目录和.vimrc文件:

sudo mkdir ~/.vim
sudo touch ~/.vimrc

安装vundle

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

上述命令可能会显示权限不够,在前面加上sudo即可。
在.vimrc配置文件中添加vundle支持

filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

安装插件

bundle分为三类,比较常用就是第二种:
在Github vim-scripts 用户下的repos,只需要写出repos名称
在Github其他用户下的repos, 需要写出”用户名/repos名”
不在Github上的插件,需要写出git全路径

将安装的插件在~/.vimrc配置:

" Define bundles via Github repos
Bundle 'christoomey/vim-run-interactive'
Bundle 'Valloric/YouCompleteMe'
Bundle 'croaky/vim-colors-github'
Bundle 'danro/rename.vim'
Bundle 'majutsushi/tagbar'
Bundle 'kchmck/vim-coffee-script'
Bundle 'kien/ctrlp.vim'
Bundle 'pbrisbin/vim-mkdir'
Bundle 'scrooloose/syntastic'
Bundle 'slim-template/vim-slim'
Bundle 'thoughtbot/vim-rspec'
Bundle 'tpope/vim-bundler'
Bundle 'tpope/vim-endwise'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-surround'
Bundle 'vim-ruby/vim-ruby'
Bundle 'vim-scripts/ctags.vim'
Bundle 'vim-scripts/matchit.zip'
Bundle 'vim-scripts/tComment'
Bundle "mattn/emmet-vim"
Bundle "scrooloose/nerdtree"
Bundle "Lokaltog/vim-powerline"
Bundle "godlygeek/tabular"
Bundle "msanders/snipmate.vim"
Bundle "jelera/vim-javascript-syntax"
Bundle "altercation/vim-colors-solarized"
Bundle "othree/html5.vim"
Bundle "xsbeats/vim-blade"
Bundle "Raimondi/delimitMate"
Bundle "groenewege/vim-less"
Bundle "evanmiller/nginx-vim-syntax"
Bundle "Lokaltog/vim-easymotion"
Bundle "tomasr/molokai"
Bundle "klen/python-mode"

打开vim(需要root 权限,即sudo vim),运行:BundleInstall或在shell中直接运行vim +BundleInstall +qall

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值