Missmiaom
10/31/2019 - 2:11 PM

vim

替换文本

[addr]s/<源字符串>/<目的字符串>/[option]

[addr]

  • "1, n":表示从第 1 行到 n 行。
  • %:表示整个文件,同 "1, $"

[option]

  • g:全局替换。
  • c:进行确认。
  • i:不区分大小写。

纵向编辑

ctrl + v 进入 VISUAL 模式,移动光标竖向选择。

  • shift + i 进行插入
  • d 删除选择部分

标签页

  • gt 跳转后一个标签页
  • gT 跳转前一个标签页

.vimrc

按键映射:

  • inoremap :只在insert模式下生效
  • vnoremap :只在visual模式下生效
  • nnoremap :只在normal模式下生效

更新vim8:

vim8 release: https://github.com/vim/vim/releases

最好安装python3.6,然后再编译vim,python3.6安装教程

sudo yum -y install gcc openssl-devel bzip2-devel
wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
tar xzf Python-3.6.6.tgz
cd Python-3.6.6
./configure --enable-optimizations --prefix=/home/ray02.lei/.bin
make install

源码编译安装vim8

# python3 config dir
python3.6-config --configdir
./configure --with-features=huge \
            --enable-multibyte \
            --enable-python3interp \
            --with-python3-command=python3 \
            --with-python3-config-dir=/home/ray02.lei/.bin/lib/python3.6/config-3.6m-x86_64-linux-gnu \
            --prefix=/home/ray02.lei/.bin
make install

pathogen: 插件管理器

https://github.com/tpope/vim-pathogen

主题

https://draculatheme.com/vim

syntastic: 语法检查

https://github.com/vim-syntastic/syntastic#installation

nerdtree: 项目结构树

https://github.com/scrooloose/nerdtree

新标签页打开修复文件夹打开插件 https://github.com/Nopik/vim-nerdtree-direnter

" 在新标签页中打开文件
let NERDTreeMapOpenInTab='<ENTER>'

UltiSnips: 代码片段

https://github.com/sirver/ultisnips

cd ~/.vim/bundle && git clone git://github.com/SirVer/ultisnips.git
cd ~/.vim/bundle && git clone git://github.com/honza/vim-snippets.git

YCM: 自动补全

http://www.alexeyshmalko.com/2014/youcompleteme-ultimate-autocomplete-plugin-for-vim/

yum install python-devel
cd ~/.vim/bundle
git clone https://github.com/Valloric/YouCompleteMe.git
cd YouCompleteMe
git submodule update --init --recursive
./install.sh --clang-completer
# CXX=/apps/svr/vre/bin/g++ python3 install.py --all

airline: 底部显示

https://github.com/vim-airline/vim-airline

set guifont=Ubuntu\ Mono\ derivative\ Powerline\ 13
let g:airline_powerline_fonts = 1
let g:airline_theme='deus'
let g:airline_section_b = '%{strftime("%c")}'
let g:airline_section_y = 'BN: %{bufnr("%")}'
let g:airline#extensions#tavline#enabled = 1

# 颜色显示不了解决:
vim ~/.bashrc
export TERM=screen-256color

autoclose: 括号自动关闭

https://github.com/Townk/vim-autoclose

git clone https://github.com/Townk/vim-autoclose.git  ~/.vim/bundle/vim-autoclose

fugitive: vim git命令

https://github.com/tpope/vim-fugitive

git clone https://github.com/tpope/vim-fugitive.git ~/.vim/bundle/vim-fugitive

升级git: https://phoenixnap.com/kb/how-to-install-git-on-centos-7

codequery 代码查找跳转

https://github.com/devjoe/vim-codequery

unite 界面

https://github.com/Shougo/unite.vim 拷贝到 ~/.vim/bundle