VIM配置文件
  9JCEeX0Eg8g4 2023年11月02日 40 0
" 不显示欢迎信息
set shortmess=atI

" 设置 tab 键为 4 个空格
set tabstop=4
set shiftwidth=4
set expandtab

" 语法高亮
syntax enable

" 显示行号
set number

" 自动缩进
set smartindent

" 开启搜索增强
set incsearch
set hlsearch

" 高亮显示当前行
set cursorline

" 显示命令行
set showcmd

" 设置颜色主题
colorscheme desert

" 设置字体大小
set guifont=Consolas:h12

" 设置文件类型检测
filetype on
filetype plugin on
filetype indent on

" 设置粘贴模式
set pastetoggle=<F2>

" 打开换行符显示
set listchars=tab:›\ ,trail:·
set list

" 撤销次数
set undolevels=1000

" 状态栏
set laststatus=2

" 取消备份文件
set nobackup
set noswapfile

" 保存时自动去除行末空格
autocmd FileType * autocmd BufWritePre <buffer> %s/\s\+$//e

" 文件编码设置
set fileencodings=utf-8,gbk2312,gb18030,cp936
set encoding=utf-8

" 搜索忽略大小写
set ignorecase
set smartcase



" 设置编码
set encoding=utf-8

" 设置默认缩进为 4 个空格
set tabstop=4
set shiftwidth=4
set expandtab

" 显示行号
set number

" 高亮显示当前行
set cursorline

" 自动补全括号、引号等符号
inoremap ( ()<Left>
inoremap { {}<Left>
inoremap [ []<Left>
inoremap ' ''<Left>
inoremap " ""<Left>

" 开启搜索增强
set incsearch
set hlsearch

" 高亮显示查找结果
set ignorecase
set smartcase

" 打开换行符显示
set list
set listchars=tab:» ,trail:-,extends:>,precedes:<

" 设置粘贴模式
set pastetoggle=<F2>

" 设置字体
if has('gui_running')
    set guifont=Monaco\ 12
endif

" 自动保存
augroup autosave
    autocmd!
    autocmd InsertLeave * silent! write
augroup END

" 设置主题(需安装 solarized 主题)
set t_Co=256
set background=light
colorscheme solarized

" 启用语法高亮
syntax enable

" 定义快捷键
nnoremap <C-n> :NERDTreeToggle<CR>
nnoremap <leader>f :FZF<space>
nnoremap <leader>b :Buffers<CR>
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>

" 快速移动到行首/行尾
nnoremap 0 ^
nnoremap $ g_

" 启用鼠标支持
set mouse=a

" 启动自动补全插件(需安装 Vundle 插件管理器)
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-surround'
Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'
Plugin 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plugin 'itchyny/lightline.vim'
call vundle#end()

" 启用 NERDTree 插件
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd vimenter * wincmd p
let g:NERDTreeWinSize = 25
let g:NERDTreeShowHidden = 1

" 启用 ctrlp 插件
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_custom_ignore = {
      \ 'dir':  '\.git$\|\.hg$\|\.svn$',
      \ 'file': '\.exe$\|\.dll$',
      \ }

" 启用 fzf 插件
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
nnoremap <leader>f :Files<CR>
nnoremap <leader>h :History<CR>
nnoremap <leader>g :Commits<CR>

" 启用 lightline 插件
set laststatus=2
let g:lightline = {
          \ 'colorscheme': 'solarized',
          \ }







" 永远的冰点的VIM配置件
" 2011/12/17
" imbingdian@gmail.com
" http://wlog.cn

if v:version < 700
    echoerr 'This _vimrc requires Vim 7 or later.'
    quit
endif

" 设置菜单语言
set langmenu=zh_cn

" =========
" 功能函数
" =========
" 获取当前目录
func GetPWD()
    return substitute(getcwd(), "", "", "g")
endf

" =========
" 环境配置
" =========
" 保留历史记录
set history=600

" 命令行于状态行
set ch=1
set stl=\ [File]\ %F%m%r%h%y[%{&fileformat},%{&fileencoding}]\ %w\ \ [PWD]\ %r%{GetPWD()}%h\ %=\ [Line]\ %l,%c\ %=\ %P 
set ls=2    "始终显示状态行

" 状态栏显示目前所执行的指令
set showcmd

" 控制台响铃(关闭遇到错误时的声音提示)
:set noerrorbells
:set novisualbell
:set t_vb= "close visual bell

" 行控制
set linebreak   "英文单词在换行时不被截断
set nocompatible    "设置不兼容VI
set textwidth=80    "设置每行80个字符自动换行,加上换行符
set wrap    "设置自动折行

" 缩进
set autoindent      "设置自动缩进
set smartindent     "设置智能缩进

" 行号和标尺
set number  "行号
set ruler   "在右下角显示光标位置的状态行
set rulerformat=%15(%c%V\ %p%%%)

" 标签页
set tabpagemax=20   "最多20个标签
set showtabline=2   "总是显示标签栏

" tab转化为4个字符
set tabstop=4
set expandtab
set smarttab
set shiftwidth=4
set softtabstop=4

"设置行高
set linespace=4

" 插入模式下使用 <BS>、<Del> <C-W> <C-U>
set backspace=indent,eol,start

" 自动重新读入
set autoread

" 自动改变当前目录
if has('netbeans_intg')
    set autochdir
endif

"搜索
set ignorecase     "在查找时忽略大小写
set incsearch    "关闭显示查找匹配过程
set hlsearch    "高亮显示搜索的内容

" 显示匹配的括号
" set showmatch

" 匹配配对的字符
func! MatchingQuotes()
    inoremap ( ()<left>
    inoremap [ []<left>
    inoremap { {}<left>
    inoremap " ""<left>
    inoremap ' ''<left>
endf

" 在所有模式下都允许使用鼠标,还可以是n,v,i,c等
set mouse=a

" 恢复上次文件打开位置
set viminfo='10,\"100,:20,%,n~/.viminfo
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

" Diff 模式的时候鼠标同步滚动 for Vim7.3
if has('cursorbind')
    set cursorbind
end

" =====================
" 多语言环境
"    默认为 UTF-8 编码
" =====================
if has("multi_byte")
    set encoding=utf-8
    " English messages only
    "language messages zh_CN.utf-8

    if has('win32')
        language english
        let &termencoding=&encoding
    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

filetype plugin indent on   "打开文件类型检测

" :help mbyte-IME
if has('multi_byte_ime')
    highlight Cursor guibg=#F0E68C guifg=#708090
    highlight CursorIM guibg=Purple guifg=NONE
endif

" =====================
" AutoCmd 自动运行
" =====================
if has("autocmd")

    " 括号自动补全
    func! AutoClose()
        :inoremap ( ()<ESC>i
        :inoremap " ""<ESC>i
        :inoremap ' ''<ESC>i
        :inoremap { {}<ESC>i
        :inoremap [ []<ESC>i
        :inoremap ) <c-r>=ClosePair(')')<CR>
        :inoremap } <c-r>=ClosePair('}')<CR>
        :inoremap ] <c-r>=ClosePair(']')<CR>
    endf
    
    func! ClosePair(char)
        if getline('.')[col('.') - 1] == a:char
            return "\<Right>"
        else
            return a:char
        endif
    endf
    
    augroup vimrcEx     "记住上次文件位置
        au!
        autocmd FileType text setlocal textwidth=80
        autocmd BufReadPost *
                    \ if line("'\"") > 0 && line("'\"") <= line("$") |
                    \   exe "normal g`\"" |
                    \ endif
    augroup END
    
    " Auto close quotation marks for PHP, Javascript, etc, file
    au FileType php,javascript exe AutoClose()
    au FileType php,javascript exe MatchingQuotes()
    
    " Auto Check Syntax
    " au BufWritePost,FileWritePost *.js,*.php call CheckSyntax(1)
    
    " JavaScript 语法高亮
    au FileType html,javascript let g:javascript_enable_domhtmlcss = 1
    au BufRead,BufNewFile *.js setf jquery
    
    " 打开javascript对dom、html和css的支持
    let javascript_enable_domhtmlcss=1
    
    " 给各语言文件添加 Dict
    if has('win32')
        let s:dict_dir = $VIM.'\vimfiles\dict\'
    else
        let s:dict_dir = $HOME."/.vim/dict/"
    endif
    let s:dict_dir = "setlocal dict+=".s:dict_dir
    
    au FileType php exec s:dict_dir."php_funclist.dict"
    au FileType css exec s:dict_dir."css.dict"
    au FileType javascript exec s:dict_dir."javascript.dict"
    
    " 增加 ActionScript 语法支持
    au BufNewFile,BufRead,BufEnter,WinEnter,FileType *.as setf actionscript 
    
    " CSS3 语法支持
    au BufRead,BufNewFile *.css set ft=css syntax=css3
    
    " 增加 Objective-C 语法支持
    au BufNewFile,BufRead,BufEnter,WinEnter,FileType *.m,*.h setf objc
    
    " 将指定文件的换行符转换成 UNIX 格式
    au FileType php,javascript,html,css,python,vim,vimwiki set ff=unix
    
    " 保存编辑状态
    au BufWinLeave * if expand('%') != '' && &buftype == '' | mkview | endif
    au BufRead     * if expand('%') != '' && &buftype == '' | silent loadview | syntax on | endif

endif

" =========
" 图形界面
" =========
if has('gui_running')
    " 只显示菜单
    set guioptions=mcr

    " 高亮光标所在的行
    set cursorline
    
    " 编辑器配色
    "colorscheme zenburn
    "colorscheme dusk
    "colorscheme breeze
    "colorscheme molokai
    
    set background=light "for solarized
    colorscheme solarized


    if has("win32")
        " Windows 兼容配置
        source $VIMRUNTIME/delmenu.vim
    source $VIMRUNTIME/menu.vim 
    
        " f11 最大化 /vimfiles/extra/fullscreen/gvimfullscreen.dll移动到安装目录
        "nmap <f11> :call libcallnr('gvimfullscreen.dll', 'ToggleFullScreen', 0)<cr>
        "nmap <Leader><Leader> :call libcallnr('gvimfullscreen.dll', 'ToggleFullScreen', 0)<cr>
    
        " 自动最大化窗口
        au GUIEnter * simalt ~x
    
        " 给 Win32 下的 gVim 窗口设置透明度 http://www.vim.org/scripts/script.php?script_id=687
        "/vimfiles/extra/vimtweak/vimtweak.dll移动到安装目录
        " au GUIEnter * call libcallnr("vimtweak.dll", "SetAlpha", 250)
    
        " 字体配置
        "http://support.microsoft.com/kb/306527/zh-cn
        "set guifont=Droid\ Sans\ Mono:h10.5:cANSI
        "set guifontwide=YouYuan:h10.5:cGB2312
    
        "cygwin路径
        "set shell=d:\cygwin\bin\mintty.exe\ -
    
    endif
    
    " Under Mac
    if has("gui_macvim")
        "开启抗锯齿渲染
        set anti
        
        " MacVim 下的字体配置
        "set guifont=Courier_New:h14
        "set guifontwide=YouYuan:h14
        "set guifontwide=Microsoft\ Yahei\ Mono:h14
        "set guifontwide=YouYuan:h13
        "set guifontwide=YouYuan:h14
        "set guifont=Droid\ Sans\ Mono:h14
        "set guifontwide=Yahei_Mono:h14
        set guifont=Monaco:h14
        set guifontwide=YouYuan:h14
    
        " 半透明和窗口大小
        set transparency=2
        set lines=300 columns=120
    
        " 使用 MacVim 原生的全屏幕功能
        let s:lines=&lines
        let s:columns=&columns
    
        func! FullScreenEnter()
            set lines=999 columns=999
            set fu
        endf
    
        func! FullScreenLeave()
            let &lines=s:lines
            let &columns=s:columns
            set nofu
        endf
    
        func! FullScreenToggle()
            if &fullscreen
                call FullScreenLeave()
            else
                call FullScreenEnter()
            endif
        endf
    
        set guioptions+=e
        " Mac 下,按 \\ 切换全屏
        nmap <f11> :call FullScreenToggle()<cr>
        nmap <Leader><Leader> :call FullScreenToggle()<cr>
    
        " I like TCSH :^)
        set shell=/bin/tcsh
    
        " Set input method off
        set imdisable
    
        " Set QuickTemplatePath
        let g:QuickTemplatePath = $HOME.'/.vim/templates/'
    
        " 如果为空文件,则自动设置当前目录为桌面
        lcd ~/Desktop/
    endif
    
    " Under Linux/Unix etc.
    if has("unix") && !has('gui_macvim')
        set guifont=Courier\ 10\ Pitch\ 11
    endif

endif

" JSLint.vim
if has("win32")
    let g:jslint_command = $VIMFILES . '/extra/jsl/win/jsl.exe'
else
    let g:jslint_command = $VIMFILES . '/extra/jsl/mac/jsl'
endif
let g:jslint_highlight_color  = '#996600'
"let g:jslint_command_options = '-conf ' .  $VIMFILES . '/extra/jsl/jsl.conf -nofilelisting -nocontext -nosummary -nologo -process'
"let g:jslint_command_options = '-nofilelisting -nocontext -nosummary -nologo -process'

" =========
" 插件
" =========

" Calendar
" http://www.vim.org/scripts/script.php?script_id=52
if has("gui_macvim")
    let g:calendar_diary=$HOME.'/.vim/diary/'
endif
map cal :Calendar<cr>

" NERDTree
" http://www.vim.org/scripts/script.php?script_id=1658
let NERDTreeWinSize=22
map ntree :NERDTree <cr>
map nk :NERDTreeClose <cr>
map <leader>n :NERDTreeToggle<cr>

" 新建 XHTML 、PHP、Javascript 文件的快捷键
nmap <C-c><C-h> :NewQuickTemplateTab xhtml<cr>
nmap  <C-c><C-g> :NewQuickTemplateTab html<cr>
nmap <C-c><C-p> :NewQuickTemplateTab php<cr>
nmap <C-c><C-j> :NewQuickTemplateTab javascript<cr>
nmap <C-c><C-c> :NewQuickTemplateTab css<cr>


" jsbeauty
"http://www.vim.org/scripts/script.php?script_id=2727
" \ff


" =========
" 快捷键
" =========
" 标签相关的快捷键 Ctrl
map tn :tabnext<cr>
map tp :tabprevious<cr>
map tc :tabclose<cr>
map <C-n> :tabnew<cr>
map <C-Tab> :tabnext<cr>

"最近打开的文件
nmap <Leader>mr :MRU<cr>

"字体大小
"http://www.vim.org/scripts/script.php?script_id=2809
"<Leader>==    Begin "font size" mode 
"<Leader>++    Increment font size 
"<Leader>--    Decrement font size 
"<Leader>00    Revert to default font size 

" 在文件名上按gf时,在新的tab中打开
map gf :tabnew <cfile><cr>

" 返回当前时间
func! GetTimeInfo()
    "return strftime('%Y-%m-%d %H:%M:%S')
    return strftime('%Y-%m-%d')
endfunction

" 插入模式按 Ctrl + D(ate) 插入当前时间
imap <C-d> <C-r>=GetTimeInfo()<cr>

"F12启动firefox
if has("win32")
    map <F12> :silent! !"C:\Program Files\Mozilla Firefox\firefox.exe" % <CR>
endif

"zen-coding,(c+y+,)
let g:user_zen_expandabbr_key = '<c-e>'
let g:use_zen_complete_tag = 1

" 保证语法高亮
syntax on

" =========
" 帮助
" =========
" :shell 进入终端
" jsbeauty \ff

set helplang=cn

" =========
" js、css压缩
" =========
"autocmd BufWriteCmd *.js :call CompileJS()  "保存时自动压缩js
"默认 :Gcc 命令压缩js
"autocmd BufWriteCmd *.js :call CompressCss()  "保存时自动压缩css
"默认 :Ycc 命令压缩css





set sw=4
set ts=4
set et
set smarttab
set smartindent
set lbr
set fo+=mB
set sm
set selection=inclusive
set wildmenu
set mousemodel=popup

au FileType php setlocal dict+=~/.vim/dict/php_funclist.dict
au FileType css setlocal dict+=~/.vim/dict/css.dict
au FileType c setlocal dict+=~/.vim/dict/c.dict
au FileType cpp setlocal dict+=~/.vim/dict/cpp.dict
au FileType scale setlocal dict+=~/.vim/dict/scale.dict
au FileType javascript setlocal dict+=~/.vim/dict/javascript.dict
au FileType html setlocal dict+=~/.vim/dict/javascript.dict
au FileType html setlocal dict+=~/.vim/dict/css.dict

"
"syntastic相关
execute pathogen#infect()
let g:syntastic_python_checkers=['pylint']
let g:syntastic_php_checkers=['php', 'phpcs', 'phpmd']
"golang
"Processing... % (ctrl+c to stop)
let g:fencview_autodetect=0
set rtp+=$GOROOT/misc/vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 显示相关  
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax on
set cul "高亮光标所在行
set cuc
set shortmess=atI   " 启动的时候不显示那个援助乌干达儿童的提示  
set go=             " 不要图形按钮  
"color desert     " 设置背景主题  
color ron     " 设置背景主题  
"color torte     " 设置背景主题  
"set guifont=Courier_New:h10:cANSI   " 设置字体  
"autocmd InsertLeave * se nocul  " 用浅色高亮当前行  
autocmd InsertEnter * se cul    " 用浅色高亮当前行  
set ruler           " 显示标尺  
set showcmd         " 输入的命令显示出来,看的清楚些  
"set whichwrap+=<,>,h,l   " 允许backspace和光标键跨越行边界(不建议)  
set scrolloff=3     " 光标移动到buffer的顶部和底部时保持3行距离  
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}   "状态行显示的内容  
set laststatus=2    " 启动显示状态行(1),总是显示状态行(2)  
"set foldenable      " 允许折叠  
""set foldmethod=manual   " 手动折叠  
set nocompatible  "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限  
" 显示中文帮助
if version >= 603
	set helplang=cn
	set encoding=utf-8
endif
" 自动缩进
set autoindent
set cindent
" Tab键的宽度
set tabstop=4
" 统一缩进为4
set softtabstop=4
set shiftwidth=4
" 使用空格代替制表符
set expandtab
" 在行和段开始处使用制表符
set smarttab
" 显示行号
set number
" 历史记录数
set history=1000
"搜索逐字符高亮
set hlsearch
set incsearch
"语言设置
set langmenu=zh_CN.UTF-8
set helplang=cn
" 总是显示状态行
set cmdheight=2
" 侦测文件类型
filetype on
" 载入文件类型插件
filetype plugin on
" 为特定文件类型载入相关缩进文件
filetype indent on
" 保存全局变量
set viminfo+=!
" 带有如下符号的单词不要被换行分割
set iskeyword+=_,$,@,%,#,-
" 字符间插入的像素行数目

"markdown配置
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}   set filetype=mkd
au BufRead,BufNewFile *.{go}   set filetype=go
au BufRead,BufNewFile *.{js}   set filetype=javascript
"rkdown to HTML  
nmap md :!~/.vim/markdown.pl % > %.html <CR><CR>
nmap fi :!firefox %.html & <CR><CR>
nmap \ \cc
vmap \ \cc

"将tab替换为空格
nmap tt :%s/\t/    /g<CR>



"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""新文件标题
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"新建.c,.h,.sh,.java文件,自动插入文件头 
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.rb,*.java,*.py exec ":call SetTitle()" 
""定义函数SetTitle,自动插入文件头 
func SetTitle() 
	"如果文件类型为.sh文件 
	if &filetype == 'sh' 
		call setline(1,"\#!/bin/bash") 
		call append(line("."), "") 
    elseif &filetype == 'python'
        call setline(1,"#!/usr/bin/env python")
        call append(line("."),"# coding=utf-8")
	    call append(line(".")+1, "") 

    elseif &filetype == 'ruby'
        call setline(1,"#!/usr/bin/env ruby")
        call append(line("."),"# encoding: utf-8")
        call append(line(".")+1, "")

"    elseif &filetype == 'mkd'
"        call setline(1,"<head><meta charset=\"UTF-8\"></head>")
	else 
		call setline(1, "/*************************************************************************") 
		call append(line("."), "	> File Name: ".expand("%")) 
		call append(line(".")+1, "	> Author: ") 
		call append(line(".")+2, "	> Mail: ") 
		call append(line(".")+3, "	> Created Time: ".strftime("%c")) 
		call append(line(".")+4, " ************************************************************************/") 
		call append(line(".")+5, "")
	endif
	if expand("%:e") == 'cpp'
		call append(line(".")+6, "#include<iostream>")
		call append(line(".")+7, "using namespace std;")
		call append(line(".")+8, "")
	endif
	if &filetype == 'c'
		call append(line(".")+6, "#include<stdio.h>")
		call append(line(".")+7, "")
	endif
	if expand("%:e") == 'h'
		call append(line(".")+6, "#ifndef _".toupper(expand("%:r"))."_H")
		call append(line(".")+7, "#define _".toupper(expand("%:r"))."_H")
		call append(line(".")+8, "#endif")
	endif
	if &filetype == 'java'
		call append(line(".")+6,"public class ".expand("%:r"))
		call append(line(".")+7,"")
	endif
	"新建文件后,自动定位到文件末尾
endfunc 
autocmd BufNewFile * normal G

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"键盘命令
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:nmap <silent> <F9> <ESC>:Tlist<RETURN>
" shift tab pages
map <S-Left> :tabp<CR>
map <S-Right> :tabn<CR>
map! <C-Z> <Esc>zzi
map! <C-O> <C-Y>,
map <C-A> ggVG$"+y
map <Esc><Esc> :w<CR>
map <F12> gg=G
map <C-w> <C-w>w
imap <C-k> <C-y>,
imap <C-t> <C-q><TAB>
imap <C-j> <ESC>
" 选中状态下 Ctrl+c 复制
"map <C-v> "*pa
imap <C-v> <Esc>"*pa
imap <C-a> <Esc>^
imap <C-e> <Esc>$
vmap <C-c> "+y
set mouse=v
"set clipboard=unnamed
"去空行  
nnoremap <F2> :g/^\s*$/d<CR> 
"比较文件  
nnoremap <C-F2> :vert diffsplit 
"nnoremap <Leader>fu :CtrlPFunky<Cr>
"nnoremap <C-n> :CtrlPFunky<Cr>
"列出当前目录文件  
map <F3> :NERDTreeToggle<CR>
imap <F3> <ESC> :NERDTreeToggle<CR>
"打开树状文件目录  
map <C-F3> \be  
:autocmd BufRead,BufNewFile *.dot map <F5> :w<CR>:!dot -Tjpg -o %<.jpg % && eog %<.jpg  <CR><CR> && exec "redr!"
"C,C++ 按F5编译运行
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
	exec "w"
	if &filetype == 'c'
		exec "!g++ % -o %<"
		exec "!time ./%<"
	elseif &filetype == 'cpp'
		exec "!g++ % -std=c++11 -o %<"
		exec "!time ./%<"
	elseif &filetype == 'java' 
		exec "!javac %" 
		exec "!time java %<"
	elseif &filetype == 'sh'
		:!time bash %
	elseif &filetype == 'python'
		exec "!time python2.7 %"
    elseif &filetype == 'html'
        exec "!firefox % &"
    elseif &filetype == 'go'
"        exec "!go build %<"
        exec "!time go run %"
    elseif &filetype == 'mkd'
        exec "!~/.vim/markdown.pl % > %.html &"
        exec "!firefox %.html &"
	endif
endfunc
"C,C++的调试
map <F8> :call Rungdb()<CR>
func! Rungdb()
	exec "w"
	exec "!g++ % -std=c++11 -g -o %<"
	exec "!gdb ./%<"
endfunc


"代码格式优化化

map <F6> :call FormartSrc()<CR><CR>

"定义FormartSrc()
func FormartSrc()
    exec "w"
    if &filetype == 'c'
        exec "!astyle --style=ansi -a --suffix=none %"
    elseif &filetype == 'cpp' || &filetype == 'hpp'
        exec "r !astyle --style=ansi --one-line=keep-statements -a --suffix=none %> /dev/null 2>&1"
    elseif &filetype == 'perl'
        exec "!astyle --style=gnu --suffix=none %"
    elseif &filetype == 'py'||&filetype == 'python'
        exec "r !autopep8 -i --aggressive %"
    elseif &filetype == 'java'
        exec "!astyle --style=java --suffix=none %"
    elseif &filetype == 'jsp'
        exec "!astyle --style=gnu --suffix=none %"
    elseif &filetype == 'xml'
        exec "!astyle --style=gnu --suffix=none %"
    else
        exec "normal gg=G"
        return
    endif
    exec "e! %"
endfunc
"结束定义FormartSrc


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""实用设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("autocmd")
      autocmd BufReadPost *
          \ if line("'\"") > 0 && line("'\"") <= line("$") |
          \   exe "normal g`\"" |
          \ endif
endif
"当打开vim且没有文件时自动打开NERDTree
autocmd vimenter * if !argc() | NERDTree | endif
" 只剩 NERDTree时自动关闭
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif

" 设置当文件被改动时自动载入
set autoread
" quickfix模式
autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>
"代码补全 
set completeopt=preview,menu 
"允许插件  
"filetype plugin on
"共享剪贴板  
"set clipboard+=unnamed 
"自动保存
set autowrite
"set ruler                   " 打开状态栏标尺
"set cursorline              " 突出显示当前行
set magic                   " 设置魔术
set guioptions-=T           " 隐藏工具栏
set guioptions-=m           " 隐藏菜单栏
""set foldcolumn=0
""set foldmethod=indent 
""set foldlevel=3 
" 不要使用vi的键盘模式,而是vim自己的
set nocompatible
" 去掉输入错误的提示声音
set noeb
" 在处理未保存或只读文件的时候,弹出确认
set confirm
"禁止生成临时文件
set nobackup
set noswapfile
"搜索忽略大小写
set ignorecase




set linespace=0
" 增强模式中的命令行自动完成操作
set wildmenu
" 使回格键(backspace)正常处理indent, eol, start等
set backspace=2
" 允许backspace和光标键跨越行边界
set whichwrap+=<,>,h,l
" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key
" 通过使用: commands命令,告诉我们文件的哪一行被改变过
set report=0
" 在被分割的窗口间显示空白,便于阅读
set fillchars=vert:\ ,stl:\ ,stlnc:\
" 高亮显示匹配的括号
set showmatch
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=1
" 光标移动到buffer的顶部和底部时保持3行距离
set scrolloff=3
" 为C程序提供自动缩进
"自动补全
"":inoremap ( ()<ESC>i
"":inoremap ) <c-r>=ClosePair(')')<CR>
":inoremap { {<CR>}<ESC>O
":inoremap } <c-r>=ClosePair('}')<CR>
"":inoremap [ []<ESC>i
"":inoremap ] <c-r>=ClosePair(']')<CR>
"":inoremap " ""<ESC>i
"":inoremap ' ''<ESC>i
""function! ClosePair(char)
""	if getline('.')[col('.') - 1] == a:char
""		return "\<Right>"
""	else
""		return a:char
""	endif
""endfunction
filetype plugin indent on 
"打开文件类型检测, 加了这句才可以用智能补全
set completeopt=longest,menu
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CTags的设定  
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let Tlist_Sort_Type = "name"    " 按照名称排序  
let Tlist_Use_Right_Window = 1  " 在右侧显示窗口  
let Tlist_Compart_Format = 1    " 压缩方式  
let Tlist_Exist_OnlyWindow = 1  " 如果只有一个buffer,kill窗口也kill掉buffer  
""let Tlist_File_Fold_Auto_Close = 0  " 不要关闭其他文件的tags  
""let Tlist_Enable_Fold_Column = 0    " 不要显示折叠树  
"let Tlist_Show_One_File=1            "不同时显示多个文件的tag,只显示当前文件的
"设置tags  
set tags=tags;  
set autochdir 


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"其他东东
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"默认打开Taglist 
let Tlist_Auto_Open=0 
"""""""""""""""""""""""""""""" 
" Tag list (ctags) 
"""""""""""""""""""""""""""""""" 
let Tlist_Ctags_Cmd = '/usr/local/bin/ctags' 
let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的 
let Tlist_File_Fold_Auto_Close = 1
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim 
let Tlist_Use_Right_Window = 1 "在右侧窗口中显示taglist窗口
" minibufexpl插件的一般设置
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1  
nmap tl :Tlist<cr>

"python补全
let g:pydiction_location = '~/.vim/after/complete-dict'
let g:pydiction_menu_height = 20
let Tlist_Ctags_Cmd='/usr/local/bin/ctags'
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1


set iskeyword+=.
set termencoding=utf-8
set encoding=utf8
set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030

autocmd FileType python set omnifunc=pythoncomplete#Complete

"set nocompatible               " be iMproved
"filetype off                   " required!

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle
" required! 
Bundle 'gmarik/vundle'

" My Bundles here:
"
" original repos on github
Bundle 'tpope/vim-fugitive'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle 'Yggdroot/indentLine'
let g:indentLine_char = '┊'
"ndle 'tpope/vim-rails.git'
" vim-scripts repos
Bundle 'L9'
Bundle 'FuzzyFinder'
" non github repos
Bundle 'https://github.com/wincent/command-t.git'
Bundle 'Auto-Pairs'
Bundle 'python-imports.vim'
Bundle 'CaptureClipboard'
Bundle 'ctrlp-modified.vim'
Bundle 'last_edit_marker.vim'
Bundle 'synmark.vim'
"Bundle 'Python-mode-klen'
Bundle 'SQLComplete.vim'
Bundle 'Javascript-OmniCompletion-with-YUI-and-j'
"Bundle 'JavaScript-Indent'
"Bundle 'Better-Javascript-Indentation'
Bundle 'jslint.vim'
Bundle "pangloss/vim-javascript"
Bundle 'Vim-Script-Updater'
Bundle 'ctrlp.vim'
Bundle 'tacahiroy/ctrlp-funky'
Bundle 'jsbeautify'
Bundle 'The-NERD-Commenter'
"django
Bundle 'django_templates.vim'
Bundle 'Django-Projects'

"Bundle 'FredKSchott/CoVim'
"Bundle 'djangojump'
" ...
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"

filetype plugin indent on     " required!
"
"ctrlp设置
"
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.png,*.jpg,*.gif     " MacOSX/Linux
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe,*.pyc,*.png,*.jpg,*.gif  " Windows

let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_custom_ignore = '\v\.(exe|so|dll)$'
let g:ctrlp_extensions = ['funky']

let NERDTreeIgnore=['\.pyc']



"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Author        :       Haoming.Ju                      "
" Email         :       juhaoming@126.com               "
" Last modify   :       2020-12-16                      "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 兼容nvim
if has('nvim')
    set viminfofile=~/.vim/.nviminfo
    let g:python3_host_prog = '/usr/bin/python3.6'
else
    set viminfofile=~/.vim/.viminfo
endif


"启动语法检测
syntax enable
syntax on
filetype plugin indent on
set encoding=UTF-8

let g:startify_change_to_dir = 0
" 其他设置
set showcmd                           " 显示输入的命令
set showmatch                         " 设置匹配模式,显示匹配的括号
set mouse=a                           " 使鼠标可用
set magic                             " 设置魔术
set number                            " 显示行号
"set relativenumber                    " 显示相对行号
set nocompatible                      " 去掉讨厌的有关vi一致性模式,避免以前的版本的一些漏洞和局限
set backspace=indent,eol,start        " 使退格键可以正常使用
set noswapfile                        " 禁止生成临时文件
set foldenable                        " 开启折叠选项
set autoread                          " 当文件被改动时自动载入
set completeopt=longest,menu          " 让Vim的补全才当行为与一般IDE一致
set wildmenu
set wildmode=list:full                " 在命令行中,按下Tab键,显示当前所有可能的命令
set softtabstop=4                     " 使用退格键,删除空格时,可以一次删除四个空格
set fileformat=unix
set updatetime=300

" 设置Tab相关设置
set tabstop=4                         " 设置制表符tab键的宽度为4空格
set expandtab                         " 用空格替代制表符
set list                              " 将空格,制表等空白字符都用特殊可见字符显示出来"
set listchars=tab:>-,trail:-          " 定义显示空白字符的特殊可见字符
set shiftwidth=4                      " 自动缩进使用4个空格"
"set scrolloff=10                      " 在上下移动光标时,光标上方或者下方至少会保留显示的行数

" 设置当前缓冲区的搜索选项
set ignorecase                        " 忽略大小写
set smartcase                         " 开启智能大小写敏感
set hlsearch                          " 高亮搜索得到的结果
set incsearch                         " 开启递增搜索模式,随着键入待搜索文本,不断的进行搜索
set conceallevel=0
set laststatus=2
set nocompatible
set hidden


" 高亮光标所在行和列
"set cursorline                        " 高亮光标所在行
"set cursorcolumn                      " 高亮光标所在列
set nobackup
set nowritebackup
set t_TI= t_TE=
set fillchars=vert:\ 

"packadd termdebug


" 插件安装管理器要安装的插件列表 Base URL: https://github.com
call plug#begin('~/.config/vimPlugin')
Plug 'scrooloose/nerdcommenter'
Plug 'rking/ag.vim'
Plug 'Yggdroot/indentLine'
Plug 'easymotion/vim-easymotion'
Plug 'luochen1990/rainbow'
Plug 'itchyny/lightline.vim'
Plug 'mg979/vim-visual-multi'
Plug 'asins/vimcdoc'
Plug 'voldikss/vim-translator'
Plug 'HaomingJu/vim-mark'

Plug 'dyng/ctrlsf.vim',                 {'on': 'CtrlSF'}
Plug 'neoclide/coc.nvim'
Plug 'preservim/nerdtree',              {'on': 'NERDTreeToggle'}
Plug 'majutsushi/tagbar',               {'on': 'TagbarToggle'}
Plug 'octol/vim-cpp-enhanced-highlight',{'for': 'cpp'}
Plug 'rhysd/vim-clang-format',          {'for': 'cpp', 'on': 'ClangFormat'}
Plug 'elzr/vim-json',                   {'for': 'json'}
Plug 'Yggdroot/LeaderF',                {
            \'do': ':LeaderfInstallCExtension',
            \'on': ['LeaderfFile', 'LeaderfBufTag', 'LeaderfMru', 'LeaderfHistoryCmd', 'LeaderfBuffer']}
Plug 'mzlogin/vim-markdown-toc',        {'for': 'markdown'}
Plug 'vim-ctrlspace/vim-ctrlspace'
Plug 'mbbill/undotree'
Plug 'vimwiki/vimwiki'
Plug 'iamcco/markdown-preview.nvim'

call plug#end()

:source ~/.vim/conf/autocmd.vim
:source ~/.vim/conf/codestyle.vim
:source ~/.vim/conf/funcs.vim
:source ~/.vim/conf/keymap.vim
:source ~/.vim/conf/coc.vim

call SetRainbow()
call SetLightline()
call SetMarkdown()
call SetNERDTree()
call SetLeaderfF()
call SetTagbar()
call SetVimjson()
call SetTranslate()
call SetEasyMotion()
call SetTextRecover()
call SwitchColor()
call SetVimWiki()
call Terminal_MetaMode(0)
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  7BPBXg9HtzBk   2023年11月19日   23   0   0 yum源vimcentos
  vxoexqgjyiCS   2023年11月19日   23   0   0 linuxvim数据
  oIa1edJoFmXP   2023年11月19日   25   0   0 加载css进度条
  YKMEHzdP8aoh   2023年11月30日   33   0   0 vimUDP
  xIUntf9oR6GI   2023年11月28日   31   0   0 sedvim基础命令
  L83A5jZvvg3Q   2023年11月19日   46   0   0 vim
  vxoexqgjyiCS   2023年11月19日   24   0   0 服务器vim字符串
  vxoexqgjyiCS   2023年11月22日   23   0   0 linuxvimbash
  L83A5jZvvg3Q   2023年11月19日   26   0   0 vimpython