[转]我的vimrc设置_猪猫的博客

来源:百度文库 编辑:神马文学网 时间:2024/05/01 12:51:35

您查询的关键词是:vimrc 设置  。如果打开速度慢,可以尝试快速版;如果想保存快照,可以添加到搜藏。

(百度和网页http://hi.baidu.com/andrewhome/blog/item/560b6c953f66794dd1135e01.html的作者无关,不对其内容负责。百度快照谨为网络故障时之索引,不代表被搜索网站的即时页面。)


.error{color:#FF0000;font-size:12px}
/**/百度首页 | 百度空间 猪猫的博客帅气率真率直率性帅得不得了 主页博客相册|个人档案 |好友   查看文章   [转]我的vimrc设置2008-10-09 18:08     参考了chinaunix等论坛上的很多大虾的设置,修改成自己的使用习惯,作为备份,放在这里吧。

"Set mapleader
let g:mapleader = ","

"显示行号
set nu

"打开语法高亮
syntax on

"设置字体
set guifont=DejaVu\ Sans\ Mono\ 12

"设置缩进
set softtabstop=8
set shiftwidth=8
set expandtab

"关闭toolbar
set guioptions-=T

"关闭自动备份
set nobackup

"自动格式化
set formatoptions=tcrqn

"在行和段开始处使用制表符
set smarttab

"在normal模式下使用系统剪贴板
"set clipboard+=unnamed

"自动缩进设置
set cindent
set smartindent
set incsearch
set autoindent

"Show matching bracets
set showmatch

"Get out of VI's compatible mode
set nocompatible

"Have the mouse enabled all the time
set mouse=a

"Set to auto read when a file is changed from the outside
set autoread

"Enable filetype plugin
filetype plugin indent on

"设置配色方案为torte
"colo torte
colo desert

"设置支持的文件编码类项,目前设置为utf-8和gbk两种类型
set fileencodings=utf-8,chinese

"设置断词
set linebreak

"设置搜索结果高亮显示
set hlsearch

"设置记录的历史操作列表
set history=200

"设置折叠
set foldenable
set foldcolumn=2
set foldlevel=3

"打开目录时不显示隐藏目录和文件
let g:netrw_hide= 1
let g:netrw_list_hide= '^\..*'

"AutoCommand
"新建.c,.h.cpp,.sh,.java,.php,.py文件自动打开Taglist
autocmd BufNewFile *.[ch],*.cpp,*.sh,*.java,*.php,*.py exec ":call SetTitle()"
"读入.c,.h.cpp,.sh,.java,.php,.py文件自动打开Taglist
"autocmd BufRead *.[ch],*.cpp,*.sh,*.java,*.php,*.py exec ":Tlist"
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
"如果是新建的php文件,则自动定位到最后第二行
autocmd BufNewFile *.php normal k

"读入python文件,设置缩进格式
autocmd BufNewFile,BufRead *.py set cinwords=if,elif,else,for,while,try,expect,finally,def,class

"读入C文件,设置折叠方式为syntax
autocmd BufNewFile,BufRead *.[ch],*.cpp set foldmethod=syntax

"读入其它文件,设置折叠方式为indent
autocmd BufNewFile,BufRead *.py,*.sh,*.java,*.php set foldmethod=indent

"设置Java代码的自动补全
autocmd FileType java setlocal omnifunc=javacomplete#Complete
"autocmd FileType java set tags=./tags,./../tags,./../../tags

"设置输入代码的自动补全
"autocmd BufEnter * call DoWordComplete()

"绑定自动补全的快捷键;
imap ;

"绑定复制到系统剪贴板快捷键
vmap c "+y
nmap c "+y

"绑定粘贴系统剪贴板内容快捷键
"imap v "+p "不设置insert模式下的快捷键,因为会造成无法输入,v
vmap v "+p
nmap v "+p

"设定开关Taglist插件的快捷键为F4,可以在VIM的左侧栏列出函数列表等
map :Tlist

"设置程序的运行和调试的快捷键F5和Ctrl-F5
map :call CompileRun()
map :call Debug()

"设置tab操作的快捷键,绑定:tabnew到t,绑定:tabn, :tabp到n,
"p
map t :tabnew
map n :tabn
map p :tabp

"设置空格键开关折叠
nmap @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')

"使用r打开上次运行的命令
nmap r :

"用cscope支持
set csprg=/usr/bin/cscope
let Tlist_Ctags_Cmd='/usr/bin/ctags'
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Right_Window=1
"默认打开Taglist
"let Tlist_Auto_Open=1

"设置搜索的tags文件范围
"set tags=./tags,./../tags,./../../tags

"使用e打开当前文件同目录中的文件
if has("unix")
        map e :e =expand("%:p:h") . "/"
else
        map e :e =expand("%:p:h") . "\"
endif

"定义CompileRun函数,用来调用进行编译和运行
func CompileRun()
        exec "w"
        "C程序
        if &filetype == 'c'
                exec "!gcc % -g -o %<"
                exec "!./%<"
                "Java程序
        elseif &filetype == 'java'
                exec "!javac %"
                exec "!java %<"
                "php程序
        elseif &filetype == 'php'
                exec "!php %"
                "bash程序
        elseif &filetype == 'sh'
                exec "!bash %"
                "python程序
        elseif &filetype == "python"
                exec "!python %"
        endif
endfunc
"结束定义CompileRun

"定义Debug函数,用来调试程序
func Debug()
        exec "w"
        "C程序
        if &filetype == 'c'
                exec "!gcc % -g -o %<"
                exec "!gdb %<"
                "Java程序
        elseif &filetype == 'java'
                exec "!javac %"
                exec "!jdb %<"
                "Php程序
        elseif &filetype == 'php'
                exec "!php %"
                "bash程序
        elseif &filetype == 'sh'
                exec "!bash -x %"
                "python程序
        elseif &filetype == 'python'
                exec "!pdb %"
        endif
endfunc
"结束定义Debug

"定义函数SetTitle,自动插入文件头
func SetTitle()
        "如果文件类型为.sh文件
        if &filetype == 'sh' || &filetype == 'python'
                call setline(1, "\#========================================================================")
                call append(line("."), "\# Author: Charlse.Zhang")
                call append(line(".")+1, "\# Email: feiyuw@gmail.com")
                call append(line(".")+2, "\# File Name: ".expand("%"))
                call append(line(".")+3, "\# Description: ")
                call append(line(".")+4, "\#   ")
                call append(line(".")+5, "\# Edit History: ")
                call append(line(".")+6, "\#   ".strftime("%Y-%m-%d")."    File created.")
                call append(line(".")+7, "\#========================================================================")
                call append(line(".")+8, "")
                "其它程序文件
        else
                call setline(1, "/**")
                call append(line("."), "=========================================================================")
                call append(line(".")+1, " Author: Charlse.Zhang")
                call append(line(".")+2, " Email: feiyuw@gmail.com")
                call append(line(".")+3, " File Name: ".expand("%"))
                call append(line(".")+4, " Description: ")
                call append(line(".")+5, "   ")
                call append(line(".")+6, " Edit History: ")
                call append(line(".")+7, "   ".strftime("%Y-%m-%d")."    File created.")
                call append(line(".")+8, "=========================================================================")
                call append(line(".")+9, "**/")
                call append(line(".")+10, "")
        endif
        "如果为php文件,添加相应头和尾
        if &filetype == 'php'
                call append(0, "                call append(line("$"), "?>")
        endif
        "如果为sh文件,添加相应的头
        if &filetype == 'sh'
                call append(0, "\#!/bin/bash")
                "如果为python文件,添加相应的头和编码设定
        elseif &filetype == 'python'
                call append(0, "\#!/usr/bin/python")
                call append(1, "\# -*- coding: utf-8 -*-")
        endif
endfunc

来源于:http://hi.baidu.com/feiyuw/blog/item/848fe917c172a20cc93d6d3f.html

类别:unix/linux | 添加到搜藏 | 浏览() | 评论 (0)  /**/最近读者: 网友评论:本篇日志被作者设置为禁止发表新评论
     
©2008 Baidu