我是靠谱客的博主 激昂悟空,最近开发中收集的这篇文章主要介绍c语言shell解析配置文件,.vimrc 配置文件( 带注释),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

"==============================================================================

" => General

"==============================================================================

set nocompatible

":命令显示历史

set history=500

"去掉gvim菜单栏

"set go-=m

"去掉gvim工具栏

set go-=T

"normal模式下取消输入法

InsertLeave *    set imdisable

InsertEnter *    set noimdisable

"开启插件和缩进

filetype plugin indent on

set autoread

set mouse=a

set mousehide

"设置无响铃

set novisualbell

"字体设定

if has("win32")

set guifont=黑体:h13:cANSI

elseif has("unix")

set guifont=Andale Mono 12

endif

"设置 mapleader = ,

let g:mapleader = ","

"快速存储和关闭

nmap w :w!

nmap q :q

nmap qq :q!

nmap wq :wq

"打开最近文件

map m :MRU

map ax :!chmod a+x %

"Favorite filetypes

if has("win32")

set ffs=dos,unix,mac

elseif has("unix")

set ffs=unix,dos,mac

endif

"编码设定Encoding

set fileencoding=utf-8

set fileencodings=utf-8,gbk,utf-16,big5

set langmenu=zh_CN.UTF-8

source $VIMRUNTIME/delmenu.vim

source $VIMRUNTIME/menu.vim

language messages zh_CN.UTF-8

"==============================================================================

" => fast edit vimrc 快速编辑vimrc

"==============================================================================

if has("win32")

"Fast editing of _vimrc

map e : $VIM/_vimrc

"reload _vimrc

map s :source $VIM/_vimrc

"When .vimrc is edited, reload it

bufwritepost vimrc source /$VIM/_vimrc

elseif has("unix")

"Fast editing of .vimrc

map e :e! $HOME/.vimrc

"reload _vimrc

map s :source $HOME/.vimrc

"When .vimrc is edited, reload it

autocmd! bufwritepost vimrc source ~/.vimrc

endif

"==============================================================================

" => Serach

"==============================================================================

"忽略大小写检索

set ignorecase

"输入检索时动态变化

set incsearch

"检索高亮

set hlsearch

"==============================================================================

" => Colors and Fonts

"==============================================================================

"语法高亮 Enable syntax highlight

syntax enable

if has("gui_running")

if has("win32")

"Auto Maximize when gvim startup in Window system.

au GUIEnter * simalt ~x

endif

endif

"主题颜色设定

"colorscheme torte

"colorscheme molokai

"colorscheme lettuce

"colorscheme navajo-night

autocmd BufEnter * :syntax sync fromstart

"高亮当前行 Highlight current

set cursorline

"Display tab as >----,and trail spaces of the line as -

"set listchars=tab:>-,trail:-

"==============================================================================

" VIM userinterface

"==============================================================================

"Turn on WiLd menu

set wildmenu

set wildignore=*.bak,*.o,*.e,*~

"Always show current position

set ruler

"The commandbar is 2 high

set cmdheight=2

set showcmd

"Show line number

set number

"Do not redraw, when running macros.. lazyredraw

set lazyredraw

"Change buffer - without saving

set hidden

"Set backspace

set backspace=eol,start,indent

"Backspace and cursor keys wrap to

set whichwrap+=,[,],h,l

" 光标移动到buffer的顶部和底部时保持三行差距

set scrolloff=3

"==============================================================================

" => Status line

"==============================================================================

function! CurDir()

let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")

return curdir

endfunction

"状态栏显示参数 Format the status line

set statusline= %F%m%r%h %w CWD: %r%{CurDir()}%h Line: %l/%L:%c %p%%

set laststatus=2

"==============================================================================

" Tab configuration

"==============================================================================

"译注:将当前内容在新标签中打开

map tn :tabnew %

"译注:打开空白新标签

map te :tabedit

"译注:关闭当前标签

map tc :tabclose

"译注:移动当前标签,使用方法为

map tm :tabmove

"让 gvim 支持 Alt+n 来切换标签页

autocmd VimEnter * call BufPos_Initialize()

"==============================================================================

" for lookupfile.vim

"==============================================================================

let g:LookupFile_MinPatLength = 2 "最少输入2个字符才开始查找

let g:LookupFile_PreserveLastPattern = 0 "不保存上次查找的字符串

let g:LookupFile_PreservePatternHistory = 1 "保存查找历史

let g:LookupFile_AlwaysAcceptFirst = 1 "回车打开第一个匹配项目

let g:LookupFile_AllowNewFiles = 0 "不允许创建不存在的文件

if filereadable("./tags") "设置tag文件的名字

let g:LookupFile_TagExpr = '"./tags"'

endif

"==============================================================================

" moving around

"==============================================================================

"window move

map j

map k

map h

map l

"nomal模式下tab来切换窗口

nmap w

",v 打开水平窗口

map v :vsplit

"buffer Switch

map :bp

map :bn

"==============================================================================

" 缩进设置 Indent

"==============================================================================

"Auto indent

set autoindent

"Smart indent

set smartindent

"C-style indenting

set cindent

"Wrap lines

set wrap

"==============================================================================

" => Folding

"==============================================================================

"Enable folding, I find it very useful

set foldmethod=syntax

set nofoldenable

"==============================================================================

" => Files and backups

"==============================================================================

"Turn backup off

set nobackup

set nowritebackup

set noswapfile

"==============================================================================

" => Text options

"==============================================================================

"四字符缩进

set shiftwidth=4

set softtabstop=4

set tabstop=4

set noexpandtab

set ambiwidth=double

"自动拆分行

set linebreak

" txt file auto insert linebreak after 78 char

"au FileType txt set tw=78 fo+=Mm

" C file

"au FileType c,cpp setl sw=8 ts=8

"对C,Cpp和perl文件保存并调试

au FileType c nmap tt :w:!gcc -o %:r %

au FileType cpp nmap tt :w:!g++ -o %:r %

au FileType perl nmap tt :w:!perl %

au FileType tex nmap tt :w:!latex %:!dvipdfm %:s/.tex/.dvi/:!gnome-open %:s/.tex/.pdf/

"cmake 自动补全

au FileType cmake set dict+=$HOME/.vim/cmake.txt

"==============================================================================

"for latex-suit.vim

"==============================================================================

au FileType tex so ~/.vim/ftplugin/tex_latexSuite.vim

if has("win32")

set shellslash

endif

"filetype indent on

let g:tex_flavor = 'latex'

set grepprg=grep -nH $*

let g:Tex_CompileRule_dvi = 'latex --interaction=nonstopmode $*'

let g:Tex_CompileRule_ps = 'dvips -Ppdf -o $*.ps $*.dvi'

let g:Tex_CompileRule_pdf = 'ps2pdf $*.ps'

"==============================================================================

"some key map

"==============================================================================

",cd Switch to current dir

map cd :cd %:p:h:set tags+=tags:cs add cscope.out

"F4 保存并make

map :w!:make

"清除高亮显示

map :nohl

"Super paste 可在不同文件的文本框中复制粘贴

"插入模式下C-a全局选中

inoremap ggVG

"可视模式下对选中模块进行复制C-c或剪切C-x

vmap "+y

vmap "+x

"插入模式下C-v粘贴

inoremap :set pastemui+mv'uV'v=:set nopaste

"==============================================================================

"for a.vim

"==============================================================================

",a和,aa C/C++源文件和头文件切换

map a :A

map aa :A

",as 在竖直方向新窗口中打开对应源文件或头文件

map as :AS

",av 在水平方向新窗口中打开对应源文件或头文件

map av :AV

",at 在新标签页中打开对应源文件或头文件

map at :AT

"==============================================================================

"for NERD_commenter.vim 智能注释

"==============================================================================

"空格键添加去除注释

"map ci

map NERDCommenterInvert

let NERDCreateDefaultMappings=0

"==============================================================================

"for NERD_tree.vim

"==============================================================================

map :NERDTreeToggle

let NERDChristmasTree=1

let NERDTreeAutoCenter=1

let NERDTreeShowLineNumbers=1

let NERDTreeWinPos='right'

let NERDTreeWinSize=30

"==============================================================================

"for taglist.vim

"==============================================================================

map :TlistToggle

let Tlist_Enable_Fold_Column = 0

let Tlist_WinWidth = 25

let Tlist_Show_One_File = 1

let g:Tb_ForceSyntaxEnable = 1

"==============================================================================

"for OmniCppComplete.vim 补全插件

"==============================================================================

set completeopt=menu

let OmniCpp_ShowPrototypeInAbbr = 1

let OmniCpp_DefaultNamespaces = ["std"] " 逗号分割的字符串

let OmniCpp_MayCompleteScope = 1

let OmniCpp_ShowPrototypeInAbbr = 1

let OmniCpp_SelectFirstItem = 2

" c-j自动补全,当补全菜单打开时,c-j,k上下选择

"imap pumvisible()?"":""

"imap pumvisible()?"":""

" f:文件名补全,l:行补全,d:字典补全,]:tag补全

"imap

"imap

"imap

"imap

"==============================================================================

"for DoxygenToolkit.vim doxygen注释插件

"==============================================================================

let g:DoxygenToolkit_authorName = "Xu Wenzhang(xwz), carl.xwz@gmail.com, http://xuwenzhang.org"

let g:DoxygenToolkit_versionString = "1.0"

"let s:licenseTag = "Copyright(C)"

"let s:licenseTag = s:licenseTag . "For free"

"let s:licenseTag = s:licenseTag . "All right reserved"

"let g:DoxygenToolkit_licenseTag = s:licenseTag

let g:DoxygenToolkit_briefTag_funcName="yes"

let g:DoxygenToolkit_briefTag_className="yes"

let g:doxygen_enhanced_color=1

", 用doxygen模式来注释

map :Dox

",hd 加入doxygen注释文件头

map hd gg:DoxLic:DoxAuthor

"==============================================================================

"for c-support

"==============================================================================

"c-support时间格式设定

let g:C_FormatDate = '%F'

let g:C_FormatTime = '%H:%M'

let g:C_FormatYear             = 'year %Y'

"==============================================================================

"for vimwiki

"==============================================================================

let g:vimwiki_use_mouse = 1

"设置vimwiki目录

let g:vimwiki_list = [{'path': '~/vimwiki/wiki/', 'path_html': '~/vimwiki/html/'}]

"au filetype vimwiki map tt VimwikiToggleListItem

"打开当前链接

au filetype vimwiki map wf VimwikiFollowLink

"在新窗口中打开当前链接

au filetype vimwiki map we VimwikiSplitLink

"在新标签中打开日志wiki,即以当天日期命名的wiki

au filetype vimwiki map dt VimwikiTabMakeDiaryNote

"保存当前文件,将当前vimwiki文件转为html,并且打开当前网页

au filetype vimwiki map tt :w:Vimwiki2HTML:!google-chrome %:p:s?/wiki/?/html/?:s?.wiki?.html?

"保存所有文件,将所有vimwiki文件转为html,并且打开当前网页

au filetype vimwiki map ta :wa:VimwikiAll2HTML:!google-chrome %:p:s?/wiki/?/html/?:s?.wiki?.html?

"==============================================================================

"for ScrollColor.vim

"==============================================================================

"浏览主题颜色

map :NEXTCOLOR

map :PREVCOLOR

"==============================================================================

"for ctags

"==============================================================================

map :call Do_CsTag()

Do_CsTag()

let dir = getcwd()

"先删除已有的tags和cscope文件,如果存在且无法删除,则报错。

if ( DeleteFile(dir, "tags") )

return

endif

if ( DeleteFile(dir, "cscope.files") )

return

endif

if ( DeleteFile(dir, "cscope.out") )

return

endif

if(executable('ctags'))

" execute "!g++ -E % -o tmpcpp -I../eg"

execute "!ctags -R --c++-kinds=+p --fields=+ialS --extra=+q --language-force=C++ ."

"silent! execute "!unlink tmpcpp"

endif

if(executable('cscope') && has("cscope") )

if(has("win32"))

silent! execute "!dir /s/b *.c,*.cpp,*.h,*.java,*.cs >> cscope.files"

else

silent! execute "!find . -iname '*.[ch]' -o -name '*.cpp' > cscope.files"

endif

silent! execute "!cscope -b"

execute "normal :"

if filereadable("cscope.out")

execute "cs add cscope.out"

endif

endif

" 刷新屏幕

execute "redr!"

endfunction

DeleteFile(dir, filename)

if filereadable(a:filename)

if (has("win32"))

let ret = delete(a:dir."\".a:filename)

else

let ret = delete("./".a:filename)

endif

if (ret != 0)

echohl WarningMsg | echo "Failed to delete ".a:filename | echohl None

return 1

else

return 0

endif

endif

return 0

endfunction

set tags=tags,../tags

Add_tags()

"Add tags file

if has("win32")

set tags+=

elseif has("unix")

set tags+=/usr/include/tags,/usr/src/tags

endif

"Add cscope file

if has("cscope") && has("unix")

if filereadable("/usr/src/cscope.out")

cs add /usr/src/cscope.out /usr/src/

endif

if filereadable("/usr/include/cscope.out")

cs add /usr/include/cscope.out /usr/include/

endif

endif

endfunction

" cscope 绑定

if has("cscope")

set csto=1

set cst

set nocsverb

if filereadable("cscope.out")

cs add cscope.out

endif

" s: C语言符号 g: 定义 d: 这个函数调用的函数 c: 调用这个函数的函数

" t: 文本 e: egrep模式 f: 文件 i: include本文件的文件

nmap ss :cs find s =expand("")

nmap sg :cs find g =expand("")

nmap sc :cs find c =expand("")

nmap st :cs find t =expand("")

nmap se :cs find e =expand("")

nmap sf :cs find f =expand("")

nmap si :cs find i ^=expand("")$

nmap sd :cs find d =expand("")

endif

"用A-Num来切换标签

BufPos_ActivateBuffer(num)

let l:count = 1

for i in range(1, bufnr("$"))

if buflisted(i) && getbufvar(i, "&modifiable")

if l:count == a:num

exe "buffer " . i

return

"endif

let l:count = l:count + 1

endif

endfor

echo "No buffer!"

endfunction

function! BufPos_Initialize()

for i in range(0, 9)

exe "map " . i . "gt"

endfor

endfunction

"进入文件所在目录然后

cd %:p:h

"set tags+=tags

"cs add cscope.out

最后

以上就是激昂悟空为你收集整理的c语言shell解析配置文件,.vimrc 配置文件( 带注释)的全部内容,希望文章能够帮你解决c语言shell解析配置文件,.vimrc 配置文件( 带注释)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(46)

评论列表共有 0 条评论

立即
投稿
返回
顶部