因为Windows的配置较麻烦,推荐在Linux下使用vim。Linux发行版通常已经装有vi,部分也带有vim,若是没有预装可使用命令安装git
sudo apt-get install vim vim-scripts vim-doc
其中vim-scripts是vim的一些基本插件,包括语法高亮的支持、缩进等等。github
pacman -S vim
vim
其中能够看到user vimrc file,即vim的用户配置文件,为 "$HOME/.vimrc"
,修改其中的内容就能够达到设置vim的目的bash
vim的基本操做能够下载一个 neovim
的一个自带GUI版本 oni
来学习。curl
oni
中自带有vim的键位教程,教程经过一系列提示操做来学习vim的经常使用键位。编辑器
oni:
github.com/onivim/oniide
截图:post
vim的插件是一系列.vim后缀的文件,一个个安装vim插件十分麻烦,因此咱们须要 插件管理器
来安装管理插件。热门的插件管理器有不少,这里介绍 Plug
。学习
Plug
的 github 项目地址: github.com/junegunn/vi…fetch
折腾vim的必备技能就是阅读插件的文档和vim的帮助文件
Plug
的文档说明了须要下载 plug.vim
放到autoload
文件夹中。能够经过 curl
轻松作到。
Installation
Download plug.vim and put it in the "autoload" directory.
Vim
Unix
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Usage
Add a vim-plug section to your
~/.vimrc
(or~/.config/nvim/init.vim
for Neovim):
Begin the section with
call plug#begin()
- List the plugins with
Plug
commandscall plug#end()
to update&runtimepath
and initialize plugin system
- Automatically executes
filetype plugin indent on
andsyntax enable
. You can revert the settings after the call. e.g.filetype indent off
,syntax off
, etc.
Example
" Specify a directory for plugins " - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin' call plug#begin('~/.vim/plugged') " Make sure you use single quotes
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align Plug 'junegunn/vim-easy-align' " Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" Multiple Plug commands can be written in a single line using | separators Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' " On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Using a non-master branch Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' } " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }
" Plugin options Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' } " Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Unmanaged plugin (manually installed and updated) Plug '~/my-prototype-plugin' " Initialize plugin system
call plug#end()
复制代码
将上面格式的代码写到 .vimrc
后就可使用:PlugInstall
命令安装上述插件了。
须要注意
"
开头的行是注释
下面是一段示例代码
call plug#begin('~/.vim/plugged')
Plug 'vim-airline/vim-airline'
call plug#end()
复制代码
输入上述代码后从新载入 .vimrc
文件便可使用 :PlugInstall
命令安装 vim-airline
插件,经常使用的命令还有:
PlugStatus
查看插件状态
PlugUpdate
安装或升级插件
PlugUpgrade
升级Plug
插件自身
其余命令请自行阅读项目文档。
github上有许多现成的配置,若是你以为折腾vim费时费力能够选择一个现成的配置使用,具体使用方法请见配置说明文档。
spacevim
:
github.com/SpaceVim/Sp… (有中文文档,各类功能较齐全)
spf13-vim
:
github.com/spf13/spf13…
amix/vimrc
github.com/amix/vimrc