-
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
If you are behind a corporate proxy, python may raise error like:
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>
To fix it, we must export the corporate’s proxy and import it into Ubuntu.
Click the lock button before the URL in Chrome's address bar. Click the certificate, show details, and export it to file (please choose BASE64 encoding): foo.crt. $ cp foo.crt /usr/local/share/ca-certificates/ $ sudo update-ca-certificates --verbose
- 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
Download it fugitive.vim, and unzip into ~/.vim/.
Download it a.vim into ~/.vim/plugin/a.vim.
:A Switch between header file and source file. Ctrl+^ also works. :AS A and split windows horizontally. :AV A and split windows vertically. :AT A and new tab window. :AN Switch among several matched files. Treat the word beside the cursor as file name, then :IH Switch into the file. :IHS IH and split windows. :IHV IH and split windows. :IHT IT and new tab. :IHN Switch among several matched files. 快捷键操作 <Leader>ih 切换至光标所在文件* <Leader>is 切换至光标所在处(单词所指)文件的配对文件(如光标所在处为foo.h,则切换至foo.c/foo.cpp...) <Leader>ihn 在多个匹配文件间循环切换 *<Leader>指Vim所定义的映射(map)前缀,在Vim配置文件中可过变量'mapleader'进行设置,缺省为'\'。
~/.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 到上一折叠的末尾
Created by Wenliang Zhang.