将vim变为IDE(不定期更新)

今天重新配置了一下vim,将其配置成为了一个完整的IDE。包括自动补全,文件列表,函数列表等  

先来一张图


以下是文件配置:

set shortmess=atI   " 启动的时候不显示那个援助乌干达儿童的提示  
set nu              " 显示行号  
syntax on           " 语法高亮  
set ruler           " 显示标尺  
set showmode
set showcmd
set hlsearch
set nocompatible  "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限  
set cursorcolumn   "竖行高亮
set cursorline     "当前横行高亮

set foldmethod=indent "设置折叠   
set foldlevelstart=99
let g:SimpylFold_docstring_preview=1

set autoindent   "自动缩进
set tabstop=4
set softtabstop=4
set shiftwidth=4
set relativenumber           "设置相对行号


"配色方案
set t_Co=256
syntax enable
set background=dark
colorscheme molokai

let mapleader=";"
nmap <Leader>q :q<CR>   
nmap <Leader>w :w<CR>
nmap <Leader>qa :qa<CR>
nmap <Leader>wq :wq<CR>

"折叠和打开
nmap <Leader>a za            

"窗口移动
nmap <Leader>j <C-W>j 
nmap <Leader>k <C-W>k
nmap <Leader>h <C-W>h
nmap <Leader>l <C-W>l

"创建新的窗口
nmap <Leader>g :Te<Space><CR>

"窗口切换
nmap <Leader>t gt

"文件切换
nmap <Leader>f gf


"方便行数跳转
nmap + :+
nmap - :-

nmap <C-U> <C-v>^d
nmap <C-K> <C-v>$hd

nmap <CR> G
nmap <backspace> gg


inoremap jk <Esc>
inoremap ( ()<LEFT>
inoremap [ []<LEFT>
inoremap { {}<LEFT>
"inoremap { <CR><Tab>{<CR>}<ESC>O<Tab>  


"插入文件开头
function HeaderPython()
    call setline(1, "#coding: utf-8")
    call append(1, "\#Created Time: ".strftime('%Y-%m-%d %T', localtime()))
		call append(2,"")
    normal G
endf

function Headersh()
    call setline(1,"\#########################################################################") 
		call append(1,"\#File Name:".expand("%"))
		call append(2,"\#Created Time:".strftime('%Y-%m-%d %T'))
                call append(3, "\#########################################################################") 
                call append(4, "\#!/bin/bash") 
		call append(5,"")
		normal G
endf

function Headercpp()
		call setline(1,"/*******************************************************")
		call append(1,"File Name:".expand("%"))
		call append(2,"Created Time:".strftime('%Y-%m-%d %T'))
		call append(3,"********************************************************/")
		call append(4,"\#include<iostream>")
		call append(5,"using namespace std;")
		call append(6,"")
		normal G
endf

function Headerdot()
		call setline(1,"//usr/bin/dot")
		call append(1,"digraph G{")
		call append(2,"")
		call append(3,"}")
		normal 3G
endf

function Headercs()
		call setline(1,"//File Name".expand("%"))
		call append(1,"//Created Time:".strftime('%Y-%m-%d &T'))
		call append(2,"using System;")
		call append(3,"namespace Hello")
		call append(4,"{")
		call append(5,"    static void Main()")
		call append(6,"    {")
		call append(7,"        ")
		call append(8,"    }")
		call append(9,"}")
		normal 8G
endf

autocmd bufnewfile *.py call HeaderPython()
autocmd bufnewfile *.sh call Headersh()
autocmd bufnewfile *.cpp call Headercpp()
autocmd bufnewfile *.dot call Headerdot()
autocmd bufnewfile *.cs call Headercs()


"<F5>调试代码
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
	exec "w"
	if &filetype == 'c'
    	exec "!g++ % -o %<"
	  exec "! ./%<"
	elseif &filetype == 'cpp'
	  exec "!g++ % -o %<"
	  exec "! ./%<"
	elseif &filetype == 'sh'
		exec "!chmod a+x %"
		exec "! ./%"
	elseif &filetype == 'cs'
		exec "!mono-csc %"
		exec "!wine %<"
	elseif &filetype == 'python'
		exec "!python %"
	endif
endfunc

"Plugin
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 'gmarik/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'Valloric/YouCompleteMe'
Plugin 'vim-scripts/a.vim'
Plugin 'tmhedberg/SimpylFold'
" 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
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'


"NERDTree
map <C-N> :NERDTreeToggle<CR>
let NERDTreeShowBookmarks=1 "显示书签
let NERDTreeDirArrows=0 "目录箭头 1 显示箭头  0传统+-|号
"autocmd VimEnter * NERDTree
"autocmd VimEnter * wincmd p
"autocmd VimEnter * if !argc() | NERDTree | endif

"Taglist
map <C-L> :Tlist<CR>
let Tlist_Show_One_File=0        
let Tlist_Ctags_Cmd="/usr/bin/ctags" "将taglist与ctags关联  
let Tlist_Exit_OnlyWindow=1    "最后一个窗口时退出
let Tlist_Use_Right_Window=1
let Tlist_File_Fold_Auto_Close=1
"let Tlist_Auto_Open=1

"ctags
map <F12>  :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>


"gtaphviz
let g:WMGraphviz_dot = "dot"
let g:WMGraphviz_output = "svg"
let g:WMGraphviz_viewer = "xdg-open"
let g:WMGraphviz_shelloptions = ""
let s:completion_type = 'attrs'

map <f8> :w<CR>:!dot -Tsvg -o %<.svg % && start %<.svg<CR>:!mv %<.svg svg<CR>
nmap <Leader>lv :w<CR>:GraphvizShow<CR>:!rm %<.dot.svg

inoremap <C-o> <C-x><C-o>


"LaTex
" REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.
filetype plugin on

" IMPORTANT: win32 users will need to have 'shellslash' set so that latex
" can be called correctly.
set shellslash

" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
set grepprg=grep\ -nH\ $*

" OPTIONAL: This enables automatic indentation as you type.
filetype indent on

" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'

let g:Tex_CompileRule_dvi='latex -src-specials -interaction=nonstopmode $*'
let g:livepreview_previewer = 'evince'
nmap <Leader>s :LLPStartPreview<CR>



 

稍微解释一下上面的部分配置文件


配色方案:这个需要去molokai官网下载一个molokai.vim 的文件,放入~/.vim/colors文件夹下(如果没有请新建一个)


Plugin:

这个部分就直接将代码写入~/.vimrc文件之后,重新输入:vim  ,再输入::PluginInstall  等待安装就好了(可能时间比较长)


NERDTree:

刚刚的Plugin部分已经安装好了,直接输入配置就好了


Taglist:

这个部分需要到taglist官网下载一个taglist.vim的文件,放入~/.vim/plugin文件夹下(没有就新建)。之后将上述的配置输入到.vimrc中


ctags:

这个直接通过输入:apt-get install ctags 安装,然后配置就好了 


最后说一下补全插件YouCompleteMe,出现错误可以参考 Ubuntu下安装YouCompleteMe插件这篇文章解决



2016-5-14更新:

增加了graphviz的配置

graphviz配置基本完成,功能主要如下:

简化自动补全,ctrl+x直接补全

f8自动生成.png文件

<Leader>+lv预览

自动生成文件头


配置方法参考 linux下做图工具——graphviz安装配置,但是配置文件中有关f8按键的设置,如果想要生产svg就直接使用,如果是想要生成png就用本篇博客的



2017-1-8更新:

增加c#的F5编译功能,以及生成.cs文件的头结构

前提需要安装wine,可以直接通过命令apt-get install wine进行安装



当添加新的功能时,本博客会持续更新,敬请期待



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值