代码拉取完成,页面将自动刷新
" GLOBAL 环境配置
" ------------------------------------------------------------------
"
" <leader>ig 对齐线
" <leader>ch 辅助线
set helplang=cn " 中文帮助
" set nocp 兼容
set history=500 " 保留历史
" 行控制
set linebreak " 英文单词在换行时不被截断
set nocompatible " 设置不兼容VI
"set textwidth=80 " 设置每行80个字符自动换行,加上换行符
set wrap " 设置自动折行
"set nowrap " 设置不自动换行
" 标签页
set tabpagemax=15 " 最多15个标签
"set showtabline=2 " 总是显示标签栏
set noerrorbells " 关闭错误时的声音提示
set novisualbell
set t_vb= " close visual bell
" 行号与标尺
set ruler " 右下角显示光标位置的状态行
set number " 显示行号
set cursorline " 突出显示当前行
"set rulerformat=%15(%c%V\ %p%%%)
" 制表符(设置所有的tab和缩进为4个空格)
set tabstop=4 " 设置tab键的宽度
set shiftwidth=4 " 换行时行间交错使用4个空格
" set cindent shiftwidth=4 " 自动缩进4空格
set softtabstop=4
" set expandtab " 使用空格来替换tab
set smarttab " 开启新行时使用智能 tab 缩进
set list " 显示Tab符,
set listchars=tab:\|\ , " 使用一高亮竖线代替 把符号显示为 |
" set listchars=tab:>-,trail:-
" set listchars=tab:\|\ ,nbsp:%,trail:-
highlight LeaderTab guifg=#666666 " 设定行首tab为灰色
match LeaderTab /\t/ " 匹配行首tab
" 缩进
set autoindent " 设置自动缩进
set smartindent " 设置智能缩进
" 搜索
set hlsearch " 开启高亮显示结果
set incsearch " 开启实时搜索功能
"set noincsearch " 关闭显示查找匹配过程
"set magic " Set magic on, for regular expressions
"set showmatch " Show matching bracets when text indicator is over them
"set mat=2 " How many tenths of a second to blink
set ignorecase " 搜索时无视大小写
set nowrapscan " 搜索到文件两端时不重新搜索
set showcmd " 状态栏显示目前所执行的指令
set autoread " 当文件在外部被修改,自动更新该文件
" 备份与缓存
set nobackup
set nowb
"set noswapfile
set writebackup " 设置无备份文件
" 自动完成
set complete=.,w,b,k,t,i
set completeopt=longest,menu " 只在下拉菜单中显示匹配项目,并且会自动插入所有匹配项目的相同文本
set showmatch " 显示括号配对情况
set iskeyword+=_,$,@,%,#,- " 带有如下符号的单词不要被换行分割
"set wildmenu "打开 wildmenu 选项,启动具有菜单项提示的命令行自动完成。
"set matchpairs=(:),{:},[:],<:>
"set whichwrap=b,s,<,>,[,]
set backspace=2 " 设置退格键可用
if has('mouse')
set mouse=a " 鼠标可用
endif
set ve=block "光标可以定位在没有实际字符的地方
"set fullscreen " 启动后自动全屏
set nocompatible " 关闭兼容模式
set hidden " 允许在有未保存的修改时切换缓冲区
"set relativenumber " 行标跟随
set clipboard+=unnamed " 共享外部剪贴板
set autochdir " 设定文件浏览器目录为当前目录
colorscheme default " 配色方案
filetype indent on " 针对不同的文件类型采用不同的缩进格式
filetype plugin on " 针对不同的文件类型加载对应的插件
filetype plugin indent on
filetype on " for taglist
" 默认为 UTF-8 编码
"---------------------------------------------------------------------------
if has("multi_byte")
set encoding=utf-8
" English messages only
"language messages zh_CN.utf-8
set fillchars+=stl:\ ,stlnc:\
if has('win32')
language english
let &termencoding=&encoding " 处理consle输出乱码
endif
set fencs=utf-8,gbk,chinese,latin1
set formatoptions+=mM
set nobomb " 不使用 Unicode 签名
if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
set ambiwidth=double
endif
else
echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"
endif
" 编码设置
"---------------------------------------------------------------------------
"set fileencoding=utf-8
set encoding=utf-8 "缓冲编码
set fileencodings=utf-8,cp936,gb18030,big5,gbk,euc-jp,latin1
set fileencoding=utf-8
set termencoding=utf-8 "编码转换
"set fileformats=unix
" 命令行与状态行
"---------------------------------------------------------------------------
set laststatus=2 " 开启状态栏信息
set cmdheight=1 " 命令行的高度,默认为1,这里设为2
" 状态行显示的内容 [包括系统平台、文件类型、坐标、所占比例、时间等]
" set statusline=%{fugitive#statusline()}\ %F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %y%r%m%*%=\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
" set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v]\ [%p%%]\ [LEN=%L]
" line color
" now set it up to change the status line based on mode
if version >= 700
au InsertEnter * hi StatusLine term=reverse ctermbg=5 gui=undercurl guisp=Magenta
au InsertLeave * hi StatusLine term=reverse ctermfg=0 ctermbg=2 gui=bold,reverse
endif
function! InsertStatuslineColor(mode)
if a:mode == 'i'
hi statusline guibg=magenta
elseif a:mode == 'r'
hi statusline guibg=blue
else
hi statusline guibg=red
endif
endfunction
au InsertEnter * call InsertStatuslineColor(v:insertmode)
au InsertChange * call InsertStatuslineColor(v:insertmode)
au InsertLeave * hi statusline guibg=green
" 判断操作系统
if (has("win32") || has("win64") || has("win32unix"))
let g:isWin = 1
else
let g:isWin = 0
endif
" 判断是终端还是gvim
if has("gui_running")
let g:isGUI = 1
else
let g:isGUI = 0
endif
" GUI MODEL 图形界面
"---------------------------------------------------------------------------
if has("gui_running")
" colorscheme mycolor
" colorscheme neon
colorscheme smyck
" colorscheme tango2
set guifont=Monospace\ 11
"au GUIEnter * simalt ~x " 窗口启动时自动最大化
set guioptions-=m " 隐藏菜单栏
set guioptions-=T " 隐藏工具栏
set guioptions-=L " 隐藏左侧滚动条
set guioptions-=r " 隐藏右侧滚动条
"set guioptions-=b " 隐藏底部滚动条
"set showtabline=0 " 隐藏Tab栏
set lines=42
set columns=136
"set guifontset=-dt-interface
set encoding=utf-8
"language messages zh_CN.UTF-8 "解决consle输出乱码
set fdm=indent "按照缩进进行折叠 manual
set mousemodel=popup " 弹出菜单
" set langmenu=zh_CN.UTF-8 " 中文菜单
"Toggle Menu and Toolbar 使用F2隐藏/显示菜单
map <silent> <F2> :if &guioptions =~# 'T' <Bar>
\set guioptions-=T <Bar>
\set guioptions-=m <bar>
\else <Bar>
\set guioptions+=T <Bar>
\set guioptions+=m <Bar>
\endif<CR>
if has("win32")
" Windows 兼容配置
source $VIMRUNTIME/mswin.vim
" F11 最大化
map <f11> :call libcallnr('fullscreen.dll', 'ToggleFullScreen', 0)<cr>
" 字体配置
"exec 'set guifont='.iconv('Courier_New', &enc, 'gbk').':h10:cANSI'
"exec 'set guifontwide='.iconv('微软雅黑', &enc, 'gbk').':h10'
set guifont=YaHei_Consolas_Hybrid:h12:cANSI
set guifontwide=YaHei_Consolas_Hybrid:h12
endif
if has("unix") && !has('gui_macvim')
set guifont=Ubuntu\ Mono\ 11
" set guifont=Oxygen\ Mono\ 10
endif
endif
" 第80列往后加下划线
" au BufWinEnter * let w:m2=matchadd('Underlined', '\%>' . 80 . 'v.\+', -1)
" set cc+=80 " 80 列加亮
" Floding 折叠
"---------------------------------------------------------------------------
"set foldmethod=syntax " 选择代码折叠类型
"set foldlevel=100 " 禁止自动折叠
"
set foldenable " Enables folding.
" 折叠方法
" manual 手工折叠
" indent 使用缩进表示折叠
" expr 使用表达式定义折叠
" syntax 使用语法定义折叠
" diff 对没有更改的文本进行折叠
" marker 使用标记进行折叠, 默认标记是 {{{ 和 }}}
set foldmethod=manual " Set fold method to 'manual'.
""set fdc=0 " Show where folds start and end, when they are opened.
"nnoremap @=((foldclosed(line('.')) < 0 )? 'zc':'zo')
set foldtext=MyFoldText()
function! MyFoldText()
let line = getline(v:foldstart)
let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g')
return v:folddashes . sub
endfunction
" 语法高亮
"---------------------------------------------------------------------------
syntax enable " 打开语法高亮
syntax on " 开启文件类型侦测
au BufRead,BufNewFile *.txt setlocal ft=txt
au BufRead,BufNewFile *.tpl setlocal ft=smarty " 支持 Smarty
au BufRead,BufNewFile *.as setlocal ft=actionscript " 支持 ActionScript
autocmd BufRead,BufNewFile *.mxml set filetype=mxml
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
autocmd BufRead,BufNewFile *.txtfmt set filetype=txtfmt
autocmd BufRead,BufNewFile *.php set filetype=php
autocmd BufRead,BufNewFile *.c set filetype=c
autocmd BufRead,BufNewFile *.go set filetype=go
autocmd BufRead,BufNewFile *.md set filetype=markdown
au BufNewFile,BufRead,BufEnter,WinEnter,FileType *.m,*.h setf objc " 增加 Objective-C 语法支持
" fencview 自动编码识别 :FencView 查看文件编码和更改文件编码
let g:fencview_autodetect=1
" dict
autocmd FileType javascript set dictionary=~/.vim/dict/javascript.dict
autocmd FileType css set dictionary=~/.vim/dict/css.dict
autocmd FileType php set dictionary=~/.vim/dict/php_func_list.dict
" 每行超过80个的字符用下划线标示
au BufRead,BufNewFile *.asm,*.c,*.cpp,*.java,*.cs,*.sh,*.lua,*.pl,*.pm,*.py,*.rb,*.hs,*.vim 2match Underlined /.\%81v/
" 将指定文件的换行符转换成 UNIX 格式
au FileType php,javascript,html,css,python,vim,vimwiki set ff=unix
" 关闭VIM的时候保存会话,按F122读取会话
set sessionoptions=buffers,sesdir,help,tabpages,winsize
au VimLeave * mks! ~/.vim/Session.vim
nmap <F7> :so ~/.vim/Session.vim<CR>
" 自动载入VIM配置文件
" autocmd! bufwritepost vimrc source $MYVIMRC
" 自动完成括号和引号
"---------------------------------------------------------------------------
inoremap ( ()<esc>:let leavechar=")"<cr>i
inoremap [ []<esc>:let leavechar="]"<cr>i
" inoremap { {<esc>o}<esc>:let leavechar="}"<cr>O
inoremap { {}<esc>:let leavechar="}"<cr>i
inoremap ' ''<esc>:let leavechar="'"<cr>i
inoremap " ""<esc>:let leavechar='"'<cr>i
" 选中下插入括号
vnoremap ( <Esc>`>a)<Esc>`<i(<Esc>
vnoremap [ <Esc>`>a]<Esc>`<i[<Esc>
vnoremap { <Esc>`>a}<Esc>`<i{<Esc>
vnoremap " <Esc>`>a"<Esc>`<i"<Esc>
vnoremap ' <Esc>`>a'<Esc>`<i'<Esc>
" 缩写
iab idate <c-r>=strftime("%Y-%m-%d")<CR>
iab itime <c-r>=strftime("%H:%M")<CR>
iab ifile <c-r>=expand("%:t")<CR>
" 个人信息
iab iauth erasin wang <erasinoo@gmail.com>
iab igmail erasinoo@gmail.com
iab iname era
" ## 快捷键
"---------------------------------------------------------------------------
"设置','为leader快捷键
let mapleader = ","
let g:mapleader = ","
" Ctrl + S 保存文件
map <C-s> <ESC>:w <CR>
imap <C-s> <ESC>:w <CR>
vmap <C-s> <ESC>:w <CR>
" Ctrl + C 选中状态下复制
vnoremap <C-c> "+y
" Ctrl + V 粘贴剪切板中的内容
map <C-v> "+p
imap <C-v> <esc>"+pa
vmap <C-v> d"+P
" 内容全选快捷键
map <C-a> gg0vG$<cr>
" nmap <C-t> :tabnew<cr>
" nmap <C-p> :tabprevious<cr>
" nmap <C-n> :tabnext<cr>
" nmap <C-k> :tabclose<cr>
" nmap <C-Tab> :tabnext<cr>
" 选中一段文字并全文搜索这段文字
vnoremap * y/<C-h>=escape(@", '\\/.*$^~[]')<CR><CR>
vnoremap # y?<C-h>=escape(@", '\\/.*$^~[]')<CR><CR>
" 对齐字体
nnoremap <leader>av :'<,'>Align =<cr>
nnoremap <leader>al :'<,'>left<cr>
nnoremap <leader>ac :'<,'>center<cr>
nnoremap <leader>ar :'<,'>right<cr>
" 设置快速保存和退出
" 快速保存为,s
" 快速退出(保存)为,w
" 快速退出(不保存)为,q
nmap <leader>s :w!<cr>
nmap <leader>w :wq!<cr>
nmap <leader>q :q!<cr>
inoremap <expr> <leader>x "\<C-X><C-O>"
" plugins: markdown index
nnoremap <leader>m :TocdownToggle<cr>
"切换buffer
nmap bn :bn<cr>
nmap bp :bp<cr>
" ## Plugins
"---------------------------------------------------------------------------
" Plugin: Powerline
" --------------------------------------------------------------------------
" let g:Powerline_symbols = 'fancy'
"----------------------------------------------------------------------------
" Plugin: TagList
" ---------------------------------------------------------------------------
" TagList 键入:Tlist开启
" if MySys() == "windows" "设定windows系统中ctags程序的位置
" let Tlist_Ctags_Cmd = 'ctags'
" elseif MySys() == "linux" "设定windows系统中ctags程序的位置
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
" endif
map <F4> :TlistToggle<cr>
let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的
let Tlist_Compact_Format = 1 " 使用小窗口.
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Enable_Fold_Column = 0 " 使taglist插件不显示左边的折叠行
let Tlist_Use_Right_Window = 1 "在右侧窗口中显示taglist窗口
"let Tlist_Use_Left_Window = 1 " Split to the left side of the screen.
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Inc_Winwidth = 0 " 防止taglist改变终端窗口的大小
let Tlist_WinWidth = 25 " taglist窗口宽度
let Tlist_Sort_Type = 'name' " 排序 name.
" ---------------------------------------------------------------------------
" Plugin: ctags for mincomp 自动加载
"---------------------------------------------------------------------------
set tags=tags
set tags+=./tags " add current directory's generated tags file
set tags+=~/program/tags " add new tags file
"---------------------------------------------------------------------------
" Plugin: omnicppcomplete
"---------------------------------------------------------------------------
set completeopt=longest,menu " I really HATE the preview window!!!
let OmniCpp_NameSpaceSearch=1 " 0: namespaces disabled
" 1: search namespaces in the current buffer [default]
" 2: search namespaces in the current buffer and in included files
let OmniCpp_GlobalScopeSearch=1 " 0: disabled 1:enabled
let OmniCpp_ShowAccess=1 " 1: show access
let OmniCpp_ShowPrototypeInAbbr=1 " 1: display prototype in abbreviation
let OmniCpp_MayCompleteArrow=1 " autocomplete after ->
let OmniCpp_MayCompleteDot=1 " autocomplete after .
let OmniCpp_MayCompleteScope=1 " autocomplete after ::
"let OmniCpp_DisplayMode=1
" c-j自动补全,当补全菜单打开时,c-j,k上下选择
imap <expr> <c-j> pumvisible()?"\<C-N>":"\<C-X><C-O>"
imap <expr> <c-k> pumvisible()?"\<C-P>":"\<esc>"
" f:文件名补全,l:行补全,d:字典补全,]:tag补全
imap <C-]> <C-X><C-]>
imap <C-F> <C-X><C-F>
imap <C-D> <C-X><C-D>
imap <C-L> <C-X><C-L>
" 提示类型加载
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
" ---------------------------------------------------------------------------
" Plugin: NERDTree
" ----------------------------------------------------------------------------
" plugin - NERD_tree.vim 以树状方式浏览系统中的文件和目录
" :NERDtree 打开NERD_tree :NERDtreeClose 关闭NERD_tree
" o 打开关闭文件或者目录 t 在标签页中打开
" T 在后台标签页中打开 ! 执行此文件
" p 到上层目录 P 到根目录
" K 到第一个节点 J 到最后一个节点
" u 打开上层目录 m 显示文件系统菜单(添加、删除、移动操作)
" r 递归刷新当前目录 R 递归刷新当前根目录
"---------------------------------------------------------------------------
let NERDTreeShowBookmarks=1 " 一直显示书签
let loaded_netrwPlugin = 0 " 不启动netrw
let NERDTreeCaseSensitiveSort=1 " 让文件排列更有序
let NERDTreeHijackNetrw = 0 " 输入:e filename不再显示netrw,而是显示nerdtree
let NERDTreeChDirMode = 2 " 改变tree目录的同时不改变工程的目录
let NERDTreeWinPos = 'left' " NERDTree显示位置在窗口右侧
let NERDTreeWinSize = 25 " NERDTREE的大小
let NERDTreeIgnore = [ '^\.svn$','^\.git$','\~$' ] " 忽略.svn .git的显示
" F3 NERDTree 切换
map <F3> :NERDTreeToggle<CR>
imap <F3> <ESC>:NERDTreeToggle<CR>
"---------------------------------------------------------------------------
" Plugin: NERD_commenter.vim 注释代码用的
"---------------------------------------------------------------------------
" 将 mapleader 设置为 `,`
" ,cA 在行尾插入 /* */,并且进入插入模式。 这个命令方便写注释
" ,c<space> toggle 注释
" 注:count参数可选,无则默认为选中行或当前行
"---------------------------------------------------------------------------
let NERDSpaceDelims=1 " 让注释符与语句之间留一个空格
let NERDCompactSexyComs=1 " 多行注释时样子更好看
map <leader>cc ,c<space> " 同等 ,ci 单行注释 Toggle
map <leader>cs ,cs " “性感”注释
map <leader>c$ ,c$ " 注释到尾部
map <leader>cu ,cu " 取消注释
map <leader>ca ,cA " 尾部注释
"---------------------------------------------------------------------------
" Plugin: miniBufExplorer 多个文件切换 可使用鼠标双击相应文件名进行切换
" 在 Bufe 内
" <Tab> 向前循环切换到每个buffer名上
" <S-Tab> 向后循环切换到每个buffer名上
" <Enter> 在打开光标所在的buffer
" d 删除光标所在的buffer
"---------------------------------------------------------------------------
" let g:miniBufExplorerMoreThanOne=0 " 只显示一个,否则多窗口容易出错
" let g:miniBufExplMapWindowNavVim = 1 " 允许 MinBuf 使用 ctrl-h,j,k,l 来上下左右选择窗口
let g:miniBufExplMapWindowNavArrows = 1 " 允许 MinBuf 使用 C-箭头来切换上下左右窗口
let g:miniBufExplMapCTabSwitchBufs = 1 " 允许 MiniBuf 使用 Ctrl-Tab 和 Ctrl-S-Tab来向前向后切换标签
" let g:miniBufExplModSelTarget = 1
"---------------------------------------------------------------------------
" Plugin: DoxygenToolkit
"---------------------------------------------------------------------------
let g:DoxygenToolkit_versionString = "1.0"
let g:DoxygenToolkit_authorName = "era"
let g:DoxygenToolkit_licenseTag = "Copyright (C) " . strftime("%Y") . " All rights reserved."
"---------------------------------------------------------------------------
" Plugin: Load_Template 根据文件后缀自动加载模板,使用:LoadTemplate呼出
"---------------------------------------------------------------------------
let g:template_path = '~/.vim/templates'
"---------------------------------------------------------------------------
" Plugin: indent guides 对齐线
"---------------------------------------------------------------------------
"<Leader>ig " 默认 toggle
let g:indent_guides_guide_size=1 "设置宽度
" ## 处理文件
"---------------------------------------------------------------------------
" **** PHP ****
" 不显示PHP变量再Taglist中
let tlist_php_settings = 'php;c:class;d:constant;f:function'
" 高亮显示sql语句
let php_sql_query = 1
" }}}
" **** Python ***
" For lines that end with \n\ or \ and continue on the next one.
"let g:pyindent_continue = '&sw - &sw'
let g:pyindent_continue = 0
autocmd Filetype python set completefunc=pythoncomplete#Complete
" 一键保存和编译
"---------------------------------------------------------------------------
" Ctrl + G 一键保存、编译
" Ctrl + R 一键保存、运行
"
" 编译C源文件
func! CompileGcc()
exec "w"
let compilecmd="!gcc -Wall -std=c99 "
let compileflag="-o %<"
exec compilecmd." % ".compileflag
endfunc
" 编译C++源文件
func! CompileCpp()
exec "w"
let compilecmd="!g++ -Wall "
let compileflag="-o %<"
exec compilecmd." % ".compileflag
endfunc
" 编译Haskell源文件
func! CompileHaskell()
exec "w"
let compilecmd="!ghc --make "
let compileflag="-o %<"
exec compilecmd." % ".compileflag
endfunc
" 编译Java源文件
func! CompileJava()
exec "w"
exec "!javac %"
endfunc
" 编译C#源文件
func! CompileCs()
exec "w"
exec "!csc %"
endfunc
" 编译Gas源文件
func! CompileGas()
exec "w"
exec "!gcc -Wall -ggdb -o %< %"
endfunc
" 运行Shell源文件
func! RunShell()
exec "w"
exec "!sh %"
endfunc
" 运行Lua源文件
func! RunLua()
exec "w"
exec "!lua %"
endfunc
" 运行Perl源文件
func! RunPerl()
exec "w"
exec "!perl %"
endfunc
" 运行Python源文件
func! RunPython()
exec "w"
exec "!python %"
endfunc
" 运行Ruby源文件
func! RunRuby()
exec "w"
exec "!ruby %"
endfunc
" 检测PHP程序语法
func! RunPHP()
exec "w"
exec "!php -l %"
endfunc
" vala
func! CompileVala()
exec "w"
exec "!valac --pkg gtk+-3.0 %"
exec "!./%<"
endfunc
" go
func! CompileGo()
exec "w"
exec "!go install"
endfunc
" 根据文件类型自动选择相应的编译函数
func! CompileCode()
exec "w"
if &filetype == "c"
exec "call CompileGcc()"
elseif &filetype == "cpp"
exec "call CompileCpp()"
elseif &filetype == "haskell"
exec "call CompileHaskell()"
elseif &filetype == "java"
exec "call CompileJava()"
elseif &filetype == "cs"
exec "call CompileCs()"
elseif &filetype == "asm"
exec "call CompileGas()"
elseif &filetype == "sh"
exec "call RunShell()"
elseif &filetype == "lua"
exec "call RunLua()"
elseif &filetype == "perl"
exec "call RunPerl()"
elseif &filetype == "python"
exec "call RunPython()"
elseif &filetype == "ruby"
exec "call RunRuby()"
elseif &filetype == "php"
exec "call RunPHP()"
elseif &filetype == "vala"
exec "call CompileVala()"
elseif &filetype == "go"
exec "call CompileGo()"
endif
endfunc
" 运行可执行文件
func! RunResult()
exec "w"
if &filetype == "c"
exec "! %<"
elseif &filetype == "cpp"
exec "! %<"
elseif &filetype == "haskell"
exec "! %<"
elseif &filetype == "java"
exec "!java %<"
elseif &filetype == "cs"
exec "! %<"
elseif &filetype == "asm"
exec "! %<"
elseif &filetype == "sh"
exec "!sh %<.sh"
elseif &filetype == "lua"
exec "!lua %<.lua"
elseif &filetype == "perl"
exec "!perl %<.pl"
elseif &filetype == "python"
exec "!python %<.py"
elseif &filetype == "php"
exec "!php -l %"
elseif &filetype == "ruby"
exec "!ruby %<.rb"
elseif &filetype == "go"
exec "!go run %"
endif
endfunc
" Ctrl + G 一键保存、编译
" Ctrl + x 一键保存、运行
map <C-g> :call CompileCode()<CR>
imap <C-g> <ESC>:call CompileCode()<CR>
vmap <C-g> <ESC>:call CompileCode()<CR>
map <leader>g :call RunResult()<CR>
imap <leader>g <ESC>:call RunResult()<CR>
vmap <leader>g <ESC>:call RunResult()<CR>
" 对齐线高亮显示
"---------------------------------------------------------------------------
" 利用自带的 cc 即 colorcolum
" 使用 ,ch 来toggle对齐线
map ,ch :call SetColorColumn()<CR>
function! SetColorColumn()
let col_num = virtcol(".")
let cc_list = split(&cc, ',')
if count(cc_list, string(col_num)) <= 0
execute "set cc+=".col_num
else
execute "set cc-=".col_num
endif
endfunction
" 简单实现鼠标提示功能
function! SimpleBallon()
return 'Cursor is at line/column: ' . v:beval_lnum .
\'/' . v:beval_col .
\ ' in file ' . bufname(v:beval_bufnr) .
\ '. word under cursor is: "' . v:beval_text . '"'
endfunction
" if g:isGUI
" set balloonexpr=SimpleBallon()
" set ballooneval
" endif
" set runtimepath+=~/.vim/helpdoc/
"autocmd BufWritePost *.php :call RunPHP()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。