从此一张.vimrc 的conf文件走天下。
将自己配置贴上来,vim常规配置 . 注释使用英文, 便于复制黏贴无乱码.
慢慢按需添加, 而不是随便从网上贴一份过来.
" ```````````````````````````````````````````````
" General Setting of Vim
" ..............................................
set number
set nowrap
set nocompatible
" Backup cancel
set nobackup
set nowb
set noswapfile
set ignorecase
set ruler
set tabstop=4
set paste
autocmd! bufwritepost $HOME/.vimrc source %
syntax on
filetype off
filetype plugin indent on
Vundle 安装的插件的一些设置
" ----------------------------------------------
" Plugins Content & Plugins settings
" .............................................
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
" Bottom Line
Plugin 'Lokaltog/vim-powerline'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'Xuyuanp/nerdtree-git-plugin'
" NerdTree
autocmd vimenter * NERDTree
map :NERDTreeToggle
let NERDTreeShowHidden=1
let g:NERDTreeShowIgnoredStatus = 1
let g:nerdtree_tabs_open_on_console_startup=1
"let g:NERDTreeIndicatorMapCustom = {
" \ "Modified" : "✹",
" \ "Staged" : "✚",
" \ "Untracked" : "✭",
" \ "Renamed" : "➜",
" \ "Unmerged" : "═",
" \ "Deleted" : "✖",
" \ "Dirty" : "✗",
" \ "Clean" : "✔︎",
" \ 'Ignored' : '☒',
" \ "Unknown" : "?"
" \ }
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'
" Powerline
set rtp+=~/.vim/bundle/vim-powerline/plugin/Powerline.vim
set laststatus=2
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
" Theme
Plugin 'altercation/vim-colors-solarized'
Plugin 'tomasr/molokai'
Plugin 'vim-scripts/phd'
" Coding
" Plugin 'Valloric/YouCompleteMe'
" Web Front-end
" Emmet
Plugin 'mattn/emmet-vim'
let g:user_emmet_leader_key=''
let g:user_emmet_settings = {
\ 'javascript.jsx' : {
\ 'extends' : 'jsx',
\ },
\ }
" html 5
Plugin 'othree/html5.vim'
" css 3
Plugin 'hail2u/vim-css3-syntax'
Plugin 'ap/vim-css-color'
augroup VimCSS3Syntax
autocmd!
autocmd FileType css setlocal iskeyword+=-
augroup END
" JavaScipt
Plugin 'pangloss/vim-javascript'
let g:javascript_plugin_jsdoc = 1
let g:javascript_plugin_ngdoc = 1
let g:javascript_plugin_flow = 1
set foldmethod=syntax
let g:javascript_conceal_function = "ƒ"
let g:javascript_conceal_null = "ø"
let g:javascript_conceal_this = "@"
let g:javascript_conceal_return = "⇚"
let g:javascript_conceal_undefined = "¿"
let g:javascript_conceal_NaN = "ℕ"
let g:javascript_conceal_prototype = "¶"
let g:javascript_conceal_static = "•"
let g:javascript_conceal_super = "Ω"
let g:javascript_conceal_arrow_function = "⇒"
let g:javascript_conceal_noarg_arrow_function = " "
let g:javascript_conceal_underscore_arrow_function = " "
set conceallevel=1
" Prettier
Plugin 'prettier/vim-prettier', {
\ 'do': 'yarn install',
\ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql'] }
let g:prettier#config#bracket_spacing = 'true'
let g:prettier#config#jsx_bracket_same_line = 'false'
let g:prettier#autoformat = 0
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql PrettierAsync
" Markdown
Plugin 'suan/vim-instant-markdown'
call vundle#end()
问题 1.
通过 Xshell 连接远程的机器, 看不到 Powerline 或者 Airline 的酷炫彩色效果.
原因:
和Xshell 等这类虚拟终端有关.因为是远程连接, 配色上的传输和虚拟终端的配置有关.
解决:
暂时不管色彩问题, 实际上你的配置已经生效了. 如果是在自己本地上机器看的话, 效果是有的.
问题 2:
CentOS安装插件 NerdTree并启用之后, 能够看到左侧的目录树, 但是会出现三角形符号乱码, 并且这些目录都打不开.
原因:
初步估计是和系统字符编码有关.
首先, 页面上复制过来显示正常的三角形符号一旦粘帖到 .vimrc 文件中就出现乱码, 类似 v3/4 这些个玩意儿, 导致该目录解析不正常, 以致显示和解析不是正常的目录名称, 从而打不开.
解决:
1. 更新编码支持. 具体实现没有尝试, 这里先挖坑吧.
问题 3:
安装 YCM 后启动 Vim,Vim 底部提示The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). YCM core library not detected; you need to compile YCM before using it
.
原因:
这是需要编译 YCM
解决:
1. 安装 cmake, 具体命令我就不多说了.简单
2. 进入到 YCM 插件的目录下, 找到 install.py, 执行命令"./install.py";
3. 重启 vim.
问题 4 :
YCM 报错:YouCompleteMe unavailable: requires Vim 7.4.1578+.
Info: You appear to be running the default system Vim on macOS. It reports as patch 8056, but it is really older than 1578. Please consider MacVim, homebrew Vim or a self-built Vim that satisfies the minimum requirement.
原因:
Mac 上的Vim的版本低于 YCM 的要求. 所以要更新 vim 到高级版本.
解决:
1. 使用 Brew 安装 vim. 命令: "brew install vim --with-lua --with-override-system-vi --with-python";
2. 关键: 注意退出 shell , 重进 shell. 原因是环境变量问题.
或者:
升级Mac 系统系统版本到最新版, 升级地方是到 App Store 上.
1. 用好 Github 以及对应插件官方仓库上对插件的使用说明, 配置说明;
2. 插件只是辅助, 内功更要看 vim的基础操作.