vim 编译器的配置

vim 安装解析

vim 配置

http://linux-wiki.cn/wiki/zh-hans/%E7%94%A8Vim%E7%BC%96%E7%A8%8B%E2%80%94%E2%80%94%E9%85%8D%E7%BD%AE%E4%B8%8E%E6%8A%80%E5%B7%A7

自己的配置的vim

winpos 5 5
set lines=30 columns=100
set nu
set go=
syntax on

autocmd insertLeave *se nocul
autocmd insertEnter *seS cul
set ruler
set showcmd
set cmdheight=1
set novisualbell
set nocompatible


autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()"  
func SetTitle() 
    if &filetype == 'sh' 
        call setline(1,"\#########################################################################") 
        call append(line("."), "\# File Name: ".expand("%")) 
        call append(line(".")+1, "\# Author: yangshuo") 
        call append(line(".")+2, "\# mail: [email protected]") 
        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: yangshuo") 
        call append(line(".")+2, "    > Mail: [email protected] ") 
        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")
        call append(line(".")+7, "#include")
	call append(line(".")+8, "#include")	
        call append(line(".")+9, "#include")
	call append(line(".")+10,"#include")
	call append(line(".")+11, "using namespace std;")
        call append(line(".")+12, "int main()")
	call append(line(".")+13, "{")
        call append(line(".")+14, "")
	call append(line(".")+15, "    return 0;")
	call append(line(".")+16, "}")
    endif
    if &filetype == 'c'
        call append(line(".")+6, "#include")
        call append(line(".")+7, "")
    endif
    autocmd BufNewFile * normal G
endfunc  


" 映射全选+复制 ctrl+a
map  ggVGY
map!  ggVGY
map  gg=G
" 选中状态下 Ctrl+c 复制
vmap  "+y
"去空行  
nnoremap  :g/^\s*$/d 
"比较文件  
nnoremap  :vert diffsplit 
"新建标签  
map  :tabnew  
"列出当前目录文件  
map  :tabnew .  
"打开树状文件目录  
map  \be  
"C,C++ 按F5编译运行
map  :call CompileRunGcc()
func! CompileRunGcc()
    exec "w"
    if &filetype == 'c'
        exec "!g++ % -o %<"
        exec "! ./%<"
    elseif &filetype == 'cpp'
        exec "!g++ % -o %<"
        exec "! ./%<"
    elseif &filetype == 'java' 
        exec "!javac %" 
        exec "!java %<"
    elseif &filetype == 'sh'
        :!./%
    endif
endfunc
"C,C++的调试
map  :call Rungdb()
func! Rungdb()
    exec "w"
    exec "!g++ % -g -o %<"
    exec "!gdb ./%<"
endfunc
" 自动缩进
set autoindent
set cindent
" Tab键的宽度
set tabstop=4
" 高亮显示匹配的括号
set showmatch
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=1
" 光标移动到buffer的顶部和底部时保持3行距离
set scrolloff=3
" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key



你可能感兴趣的:(操作系统)