比较麻烦,未完待续。。。。。。
VIM
强调三个概念:
A buffer is the in-memory text of a file.
A window is a viewport on a buffer.
A tab page is a collection of windows.
解释:
1. vim 把加载进内存的文件叫做 buffer,buffer 不一定可见;
2. 若要 buffer 要可见,则必须通过 window 作为载体呈现;
3. 同个看面上的多个 window 组合成一个 tab。
4. 一句话,vim 的 buffer、window、tab 你可以对应理解成视角、布局、工作区。
现在业内一般不建议用 tab,因此这里重点关注 buffer、window。
列出 | 增加 | 删除 | 选择/切换 | 退出 | 其他 |
---|---|---|---|---|---|
buffer | :ls :buffers |
:e | :bd | :bNum :bn :bp :bl :bf |
无 |
tab | :tabs | :tabe | :tabc :tabo |
gt/gT :tabp :tabn |
无 |
window | 无 | C-w + C-w - C-w > C-w < :new :vnew |
:q :qa :wqa :only C-w = C-w q C-w c C-w o |
C-w C-w C-w h/j/k/l |
无 |
file & dired | :Ex :Sex :He :Ve :Te |
无 | 无 | 无 | 无 |
其他操作 | 命令 | 命令 | 命令 | 命令 | 命令 | 命令 |
---|---|---|---|---|---|---|
其他 | u gu guu U gU gUU |
C-c | fChar | * viw |
C-o C-i |
:shell exit |
配置:.vimrc以及.ycm_extra_conf.py配置
插件:个人觉得以下几乎是必需的插件
插件
- vim-plug: 轻巧的插件管理器
- nerdtree: scrooloose/nerdtree 目录结构浏览
- YouCompleteMe: Valloric/YouCompleteMe 超级强大的自动补全,集成了具有语法检查功能的syntactic
- tagbar: majutsushi/tagbar 相当于eclipse的outline
- ctrlp: kien/ctrlp.vim 全局搜索+状态条
- powerline: powerline/powerline
- nerdcommenter:scrooloose/nerdcommenter
- vim-expand-region:terryma/vim-expand-region
- vim-surround:tpope/vim-surround
- gtags : vim-scripts/gtags.vim 让 vim 可以用 gnu-global ,gtags 要结合 gtags-cscope 一起使用
- gtags-cscope : whatot/gtags-cscope.vim
插件使用备忘
有些插件用法容易忘记,记录在这里
nerdtree
NERDTree可以很方便地进行打开文件、查找文件等操作,但是删除啊等等这些操作呢?见下图
nerdcommenter
注释:SPC c c
取消:SPC c u
安装YouCompleteMe
其他的插件都很好装,就是ycm不好装。
按照步骤来,一定能成功的。
如果哪里出错了,仔细从头地对照教程检查;如果每一步真的都是按照步骤来,一定可以成功。
安装Vundle
略
确保前提
Ensure that your version of Vim is at least 7.4.143 and that it has support for Python 2 or Python 3 scripting.
翻译: 确保Vim版本至少为7.4.143,并且它支持Python 2或Python 3脚本。
验证:
在Vim中输入 :version 可以查看版本。
After you have made sure that you have Vim 7.4.143+, type the following in Vim:
echo has('python') || has('python3')
. The output should be 1. If it’s 0, then get a version of Vim with Python support.翻译: 确定Vim 7.4.143+后,在Vim中键入以下命令:
echo has('python')|| has('python3')
,输出应为1;如果它为0,那么去装一个带有Python支持的Vim版本。
安装YouCompleteMe插件
两种方式安装:
Vundle安装:
Plugin 'Valloric/YouCompleteMe'
如果用Vundle更新YCM,yum_support_lib库API改变了,YCM会提醒你重新编译它。
git安装:先用
git clone --recursive https://github.com/Valloric/YouCompleteMe.git
获取最新的仓库;而后使用git submodule update --init --recursive
确认仓库的完整性后,开始安装流程
Download the latest version of libclang: 下载libclang(版本>=3.9)
翻译: 下载最新版本的libclang(3.9以上版本)
下载地址:http://llvm.org/releases/download.html
官方建议下二进制包:(别下错了)
- Clang for x86_64 Ubuntu 14.04 (.sig)
- Clang for x86_64 Ubuntu 16.04 (.sig)
- Clang for Mac OS X (.sig)
编译安装ycm_core库之前戏
Compile the ycm_core library that YCM needs.
This library is the C++ engine that YCM uses to get fast completions.
翻译: 编译YCM需要的
ycm_core
库。 这个库是YCM用来获得快速完成的C ++引擎。
编译安装ycm_core
需要cmake
和python-dev
支持。
安装cmake
:
- Ubuntu:
sudo apt-get install cmake
- Mac:
brew install cmake
安装python-dev
:
- Ubuntu:
sudo apt-get install python-dev python3-dev
- Mac: they should already be present(Mac下,它们是现成的,不需要额外装)
Here we’ll assume you installed YCM with Vundle.
That means that the top-l