我的vim配置

我的vim配置

1.通用配置

vimrc

2.自己配置

1.新建.c,.h,.sh,.java文件,自动插入文件头

 vim ~/.vim_runtime/my_configs.vim

输入一下内容

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""新文件标题
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"新建.c,.h,.sh,.java文件,自动插入文件头 
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()"
""定义函数SetTitle,自动插入文件头 
func SetTitle()
"如果文件类型为.sh文件 
if &filetype == 'sh'
call setline(1,"#########################################################################")
call append(line("."), "# File Name: ".expand("%"))
call append(line(".")+1, "# Author: liubiyonge")
call append(line(".")+2, "# mail: liubiyonge.com")
call append(line(".")+3, "# Created Time: ".strftime("%c"))
call append(line(".")+4, "#########################################################################")
call append(line(".")+5, "#!/bin/bash")
call append(line(".")+6, "")
else
call setline(1, "/*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: liubiyonge")
call append(line(".")+2, " > Mail: liubiyonge@163.com ")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " ************************************************************************/")
call append(line(".")+5, "")
endif
if &filetype == 'cpp'
call append(line(".")+6, "#include<iostream>")
call append(line(".")+7, "using namespace std;")
call append(line(".")+8, "")
endif
if &filetype == 'c'
call append(line(".")+6, "#include<stdio.h>")
call append(line(".")+6, "#include<stdio.h>")
call append(line(".")+7, "")
endif
" if &filetype == 'java'
" call append(line(".")+6,"public class ".expand("%"))
" call append(line(".")+7,"")
" endif
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
endfunc

autocmd BufNewFile *.py exec ":call SetTitle1()" "編制call函數要在字符串內
func SetTitle1()
call setline(1,'#!/usr/bin/env python') "注意標號爲1
call append(line("."),'#--coding:utf-8--')"注意標號爲0
call append(line(".")+1,'# Create time'.strftime('%c'))"注意標號爲1,注意加上line(".":)
call append(line(".")+2,'# Author: liubiyongge')"注意標號爲2
call append(line(".")+3,"# Email:liubiyongge@163.com")"注意標號爲3
normal G
normal o
normal o
endfunc

2.显示文件夹结构插件

需要下载 flake

 pip install flake8
  vim ~/.vim_runtime/my_configs.vim

输入一下内容

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""
"NERDtee设定
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let NERDChristmasTree=1
let NERDTreeAutoCenter=1
let NERDTreeBookmarksFile=$VIM.'DataNerdBookmarks.txt'
let NERDTreeMouseMode=2
let NERDTreeShowBookmarks=1
let NERDTreeShowFiles=1
let NERDTreeShowHidden=1
let NERDTreeShowLineNumbers=1
let NERDTreeWinPos='left'
let NERDTreeWinSize=31
map <F7> :NERDTree<CR>

3.显示近期打开文件插件

 vim ~/.vim_runtime/my_configs.vim

输入一下内容

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""
"MRU设定
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <f6> :MRU<CR>

4.显示代码树插件

『下载和安装』

     1)从http://www.vim.org/scripts/script.php?script_id=273下载安装包,也可以从http://vim-taglist.sourceforge.net/index.html下载。

    2)进入~/.vim目录,将Taglist安装包解压,解压后会在~/.vim目录中生成几个新子目录,如plugin和doc(安装其它插件时,可能还会新建autoload等其它目录)。

    3)进入~/.vim/doc目录,在Vim下运行"helptags ."命令。此步骤是将doc下的帮助文档加入到Vim的帮助主题中,这样我们就可以通过在Vim中运行“help taglist.txt”查看taglist帮助。

     vim ~/.vim_runtime/my_configs.vim

输入一下内容

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""
"Taglist设定
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let Tlist_Show_One_File=1 "不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow=1 "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Ctags_Cmd="/usr/bin/ctags" "将taglist与ctags关联
map <F5> :Tlist<CR>

5.python代码自动补全

下载Pydiction

mkdir ~/.vim
mkdir ~/.vim/bundle
cd ~/.vim/bundle
这里我们可以自己下载好上传到linux系统中
git clone https://github.com/rkulla/pydiction.git
cp -r ~/.vim/bundle/pydiction/after/ ~/.vim

6.自动补全插件

首先,从http://www.vim.org/scripts/script.php?script_id=1879处 下载autocomplpop.vim文件(我们所说的vim插件就是这样的*.vim格式的文件),然后将其放入vim文件目录下的plugin目录中 (unix/linux平台在/usr/share/vim/vim71中, windows平台在安装目录的vim71目录中),然后重启一下vim就会发现在编码时会自动弹出提示了。

7.插件管理器

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim


vim ~/.vim_runtime/my_configs.vim

输入一下内容

set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle.vim
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'

call vundle#end()
filetype plugin indent on

8. YouCompleteMe 插件

打开vim,输入:PluginInstall [需要很长时间]
sudo apt-get install build-essential cmake
sudo apt-get install python-dev python3-dev
    cd ~/.vim/bundle/YouCompeteme
./install.py --clang-completer
apt-get install vim-nox
sudo pip3 install future
进入到YouCompleteMe目录,在terminal窗口敲入git submodule update --init --recursive
curl -sSf https://static.rust-lang.org/rustup.sh | sh(或者 sudo apt-get install cargo)
python3 YouCompleteMe/install.py --clang-completer --racer-completer

最后

原文地址:https://www.cnblogs.com/liubiyonge/p/9324636.html