-
Notifications
You must be signed in to change notification settings - Fork 2
vim
- Install Vim8
For macOS, replace default vim:
$ brew install vim --with-override-system-vi --with-lua
See also the crash bug of vim.
- Install Vundle & YouCompleteMe
Read the latest document.
Install YCM, It is somewhat outdated. Verified steps for Ubuntu 20.04/21.04/macOS:
First, you will need to install Vundle, which is a plugin management tool for Vim. Run the following:
$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
Next, copy and paste the following at the top of ~/.vimrc file:
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 'VundleVim/Vundle.vim' " let Vnudle manage YCM Plugin 'Valloric/YouCompleteMe' " 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 - lists configured plugins " :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate " :PluginSearch foo - searches for foo; append `!` to refresh local cache " :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal " " see :h vundle for more details or wiki for FAQ " Put your non-Plugin stuff after this line
Next, install Vundle and YouCompleteMe in vim. To do this, open up vim and install plugins:
$ vim :PluginInstall
This command within vim will install Vundle and YouCompleteMe plugins directly from the Github repositories, so make sure that you have Internet connection. Wait until it says “Done” at the bottom of vim. If may take a while, to check the status: htop. And it may report YCM server crashes like, “The ycmd server SHUT DOWN (restart with ‘:YcmRestartServer’). YC…CM before using it. Follow the instructions in the documentation.”.
Set the two lines at the top of ~/.vimrc, and read the debug log. The error may go away after the next installation steps.
let g:ycm_server_keep_logfiles = 1 let g:ycm_server_log_level = 'debug'
$ sudo apt install build-essential cmake vim-nox python3-dev $ sudo apt install mono-complete golang nodejs default-jdk npm # optional for more languages
Next, you will need to change directory to where the YouCompleteMe is installed and setup clang-completion for C-family:
$ cd ~/.vim/bundle/YouCompleteMe $ python3 install.py --all # --all for all languages, --clangd-completer for c/c++ only
- Configure YCM to use cmake
If using CMake, add -DCMAKE_EXPORT_COMPILE_COMMANDS=ON when configuring (or add set(CMAKE_EXPORT_COMPILE_COMMANDS ON) to CMakeLists.txt). And make sure the generated file ‘compile_commands.json` is at the top dir or link to top dir.
http://stackoverflow.com/questions/23976517/vim-find-command-how-to-list-all-matched-files
~/.vimrc: colorscheme murphy, http://blog.csdn.net/linuxzhouying/article/details/6971628
$ ll /usr/share/vim/vim72/colors | awk '{print $9}' | grep -v '^$' blue.vim darkblue.vim default.vim delek.vim desert.vim elflord.vim evening.vim koehler.vim morning.vim murphy.vim pablo.vim peachpuff.vim README.txt ron.vim shine.vim slate.vim torte.vim zellner.vim
http://vim.wikia.com/wiki/Ignore_white_space_in_vimdiff
$ vimdiff -c 'set diffopt+=iwhite' ... $ cat .vimrc if &diff " diff mode set diffopt+=iwhite endif
zf 创建折叠(使用数字表示创建有当前行到下多少行的折叠,比如3j就创建包括4行的折叠) zo 打开折叠(l也可以打开折叠) zc 关闭当前折叠 zm 关闭所有折叠 zr 打开所有折叠 zE 删除所有折叠 zd 删除当前折叠 za 若当前打开则关闭,若当前关闭则打开 zj 到下一折叠的开始处 zk 到上一折叠的末尾
下载插件 a.vim 到 ~/.vim/plugin/a.vim,重启 vim 即可。
:A 头文件/源文件切换。或者Ctrl+^也可以。 :AS 分割窗后并切换头/源文件(切割为上下两个窗口) :AV 垂直切割窗口后切换头/源文件(切割为左右两个窗口) :AT 新建Vim标签式窗口后切换 :AN 在多个匹配文件间循环切换 将光标所在处单词作为文件名打开 :IH 切换至光标所在文件 :IHS 分割窗口后切换至光标所在文件(指将光标所在处单词作为文件名打开) :IHV 垂直分割窗口后切换 :IHT 新建标签式窗口后切换 :IHN 在多个匹配文件间循环切换 快捷键操作 <Leader>ih 切换至光标所在文件* <Leader>is 切换至光标所在处(单词所指)文件的配对文件(如光标所在处为foo.h,则切换至foo.c/foo.cpp...) <Leader>ihn 在多个匹配文件间循环切换 *<Leader>指Vim所定义的映射(map)前缀,在Vim配置文件中可过变量'mapleader'进行设置,缺省为'\'。
Created by Wenliang Zhang.