• vim系统配置文件,配置专属自己的环境


      1 "******************************************************特殊设置**********************************************************
      2 if strftime("%H") < 19                      "时间在7:00前
      3     colorscheme guodesert
      4 elseif strftime("%H") > 18                  "时间在19:00后
      5     colorscheme guodesert
      6     else                                    "时间在7:00~19:00之间
      7     colorscheme github
      8 endif
      9 "autocmd InsertLeave * set nocul            "浅色显示高亮行,离开时关闭
     10 autocmd InsertLeave * set nocuc             "浅色显示高亮行,离开时关闭
     11 autocmd InsertEnter * set cul               "浅色显示高亮行,进入时浅色显示打开
     12 autocmd InsertEnter * set cuc               "浅色显示高亮行,进入时浅色显示打开
     13  14 let &t_SI = "<Esc>]50;CursorShape=0x7"
     14 let &t_EI = "<Esc>]50;CursorShape=1x7"
     15 "******************************************************特殊设置**********************************************************
     16 syntax on                                   "语法高亮
     17 filetype indent on                          "文件类型侦测
     18 filetype plugin on                          "文件类型插件启用
     19 match OverLength /\%109v.+/
     20 "******************************************************选项设置**********************************************************
     21 set autochdir                           "自动切换当前目录为当前文件所在的目录
     22 set autoindent                          "插入模式下输入<cr>或使用"o""O"命令开新行,从当前行复制缩进距离
     23 set cindent                             "使用C/C++的缩进方式缩进
     24 set autoread                            "当文件在外部被修改时,自动重新读取
     25 set autowrite                           "自动保存文件
     26 set completeopt=preview,menu
     27 set complete+=k                         "关键字补全,扫描 'dictionary' 选项给出的文件
     28 "set comments                           "关键字补全,扫描 'dictionary' 选项给出的文件
     29 set cursorline                          "突出显示当前行
     30 set foldlevel=99                        "设置折叠级别: 高于此级别的折叠会被关闭
     31 set foldclose=all                       "设置为自动关闭折叠
     32 set foldenable                          "开始折叠
     33 set foldmethod=syntax                   "语法高亮项目指定折叠
     34 set foldcolumn=0                        "设置折叠区域的宽度,显示折叠列
     35 set history=512                         "命令的历史和最近搜索模式的历史被记住。本项决定分别记多少项历史
     36 set hlsearch                            "搜索时高亮显示被找到的文本
     37 set helplang=cn                         "设置帮助语言
     38 set ignorecase                          "搜索模式里忽略大小写
     39 set smartcase                           "搜索模式里包含大写字符,不使用ignorecase选项
     40 set incsearch                           "输入搜索命令时,显示目前输入的模式的匹配位置。匹配的字符串被高亮
     41 set iskeyword+=_,$,@,%,#,-              "带有这些字符的单词不要被换行分割
     42 set mousehide                           "在输入时隐藏鼠标指针,移动鼠标时恢复指针
     43 set nocompatible                        "关闭vi兼容模式
     44 set noexpandtab                         "不用空格展开<Tab>
     45 set nosplitbelow                        "窗口的分割会把新窗口放到当前窗口之下
     46 set nosplitright                        "窗口的分割会把新窗口放到当前窗口之右
     47 set number                              "在每行前面显示行号
     48 set numberwidth=3                       "行号使用的最小列数
     49 "set rulerformat =%65(%2*%<%=最近修改: \%{strftime("%H:%M",getftime(expand("%")))} | 光标: \%l行 %c%V列 | 比例:%p%%%)
     50 set rulerformat =%75(%2*%<%=字符: \%b | 修改: \%{strftime("%H:%M",getftime(expand("%")))} | 光标: \%l行 %c%V列 | \%Y \%M \%R %p%% | 编号: \%n\%)
     51 set scrolloff=1                         "光标上下两侧最少保留的屏幕行数
     52 set showcmd                             "在屏幕最后一行显示 (部分的) 命令
     53 set showmode                            "在插入、替换和可视模式里,在最后一行提供消息
     54 set showmatch                           "插入括号时,短暂地跳转到匹配的对应括号
     55 set matchtime=5                         "短暂跳转到匹配括号的时间
     56 set shiftwidth=4                        "(自动)缩进每一步使用的空白数目
     57 "set smartindent                        "开启新行时使用智能自动缩进
     58 set softtabstop=4                       "执行插入时,<Tab>算作空格的数目,可以改为4
     59 "set rtp+=/usr/lib/python3.6/site-packages/powerline/bindings/vim/ "启用powerline, laststatus=2
     60 set laststatus=1                        "2总显示最后一个窗口的状态行,1窗口多于一个时显示最后一个窗口的状态行,0不显示最后一个窗口的状态行
     61 set tabstop=4                           "执行插入时,<Tab>算作空格的数目,可以改为4
     62 set t_Co=256                            "开启vim的256颜色支持
     63 set textwidth=122                       "设定文本的宽度为122个字符时自动断行
     64 set virtualedit+=block                  "在可视模式下可以选择一个方块
     65 set wrap                                "设置文本达到textwidth宽度时自动换行,但实际文件还是一行
     66 set wildignore+=*.svn                   "文件名补全时忽略.svn
     67 set wildmenu                            "'wildmenu'打开时,命令行补全以增强模式运行
     68 set wildmode=list:full                  "用'widechar'指定的字符所用的补全模式
     69 set visualbell
     70 "set completeopt=longest,menu
     71 "set nobackup                           "覆盖文件时不备份
     72 "set writebackup                        "覆盖文件时自动备份
     73 "set hidden                             "放弃时隐藏缓冲区
     74 "set novisualbell                       "不使用可视响铃
     75 "set backspace=2                        "使用回格键
     76 "set backspace=indent,eol,start         "影响 <BS>、<Del>、CTRL-W和CTRL-U在插入模式下的工作方式
     77 "set noswapfile                         "没有交换文件
     78 "set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 "设置编码
     79 "以下用的比较少,酌情选择
     80 "set formatoptions+=q                   "描述自动排版如何进行的字母序列
     81 "set formatoptions+=r
     82 "set formatoptions+=n
     83 "set formatoptions+=1
     84 "set colorcolumn=+1
     85 "set columns=108                        "设置文本达到columns宽度时自动换行
     86 "set list                               "让tab显示成>-------->--------
     87 "set listchars=tab:>-,trail:-,extends:>,precedes:<      "配合上边的语句完成
     88 "set nowrap                             "设置文本达到textwidth宽度时不自动换行
     89 "set sidescrolloff=5                    "如果设置'nowrap',光标左右两侧保留的最少屏幕列数
     90 "set sidescroll=2                       "水平滚动时滚动的最少列数
     91 "set background=dark                    "设置背景为暗色
     92 "set cmdheight=2                        "设定命令行的行数为1
     93 "set cursorcolumn                       "突出显示当前列
     94 "set undofile                           "持久撤销功能
     95 "set ruler                              "显示状态栏标尺
     96 set tags+=./tags
     97 set tags=~/WORKM/ANDROID_SRC/
     98 "******************************************************选项设置**********************************************************
     99 101 "******************************************************杂项设置**********************************************************
    100 ab psvm public static void main                 "试试缩写好用吗
    101 let NERDTreeQuitOnOpen=1
    102 let NERDTreeDirArrows=0
    103 let NERDTreeWinSize=40
    104 let NERDRemoveExtraSpaces=0
    105 let g:bufExplorerDisableDefaultKeyMapping = 1
    106 let g:acp_behaviorKeywordCommand = "<C-o>"
    107 let g:acp_behaviorKeywordLength = -1
    108 let g:acp_behaviorFileLength = -1
    109 let g:SuperTabDefaultCompletionType = "<c-n>"
    110 let g:SuperTabLongestHighlight = 1
    111 let g:tagbar_sort=0
    112 let g:tagbar_compact=1
    113 let g:tagbar_foldlevel=1
    114 let g:tagbar_iconchars=['+', '-']
    115 let OmniCpp_SelectFirstItem = 2
    116 let OmniCpp_ShowPrototypeInAbbr = 1
    117 let OmniCpp_MayCompleteScope = 1
    118 "******************************************************杂项设置**********************************************************
    119 122 "======================================================跳转位置==========================================================
    120 if has("autocmd")                       "打开文件时,自动跳转到光标最后所在的位置
    121    au BufReadPost * if line("'"") > 0 && line("'"") <= line("$")
    122      | exe "normal! g'"" | endif
    123 endif
    124 "######################################################跳转位置##########################################################
    125 129 "======================================================添加注释==========================================================
    126 "将键盘上的F10功能键映射为添加作者信息,版权声明,文件信息,代码说明等
    127     map <F10> :call TitleDet()<cr>
    128 133 "添加文件信息
    129   function AddTitle()
    130     call append(0,"/* *=+=+=+=+* *** *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=")
    131     call append(1,"  * 作者代号: *** :guochaoxxl")
    132     call append(2,"  * 版权声明: *** :(魎魍魅魑)GPL3")
    133     call append(3,"  * 联络信箱: *** :guochaoxxl@gmail.com")
    134     call append(4,"  * 文档用途: *** :深入理解C指针")
    135     "call append(4,"  * 文档用途: *** :数据结构与算法--C语言描述")
    136     call append(5,"  * 文档信息: *** :".expand("%:p:~"))
    137     call append(6,"  * 修订时间: *** :".strftime("%Y年第%W周 %m月%d日 %A %p%I:%M (%j天)"))
    138     call append(7,"  * 代码说明: *** :自行添加")
    139     call append(8," * *+=+=+=+=* *** *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+*/")
    140   endfunction
    141 147 "更新最近修改时间和文件名
    142   function UpdateTitle()
    143     normal m'
    144     execute '/修订时间:/s@:.*$@=strftime(": *** *%Y年第%W周 %m月%d日 %A %p%I:%M (%j天)")@'
    145     normal ''
    146     normal mk
    147     execute '/文档信息:/s@:.*$@=": *** :".expand("%:p:~")@'
    148     execute "noh"
    149     normal 'k
    150   endfunction
    151 158 "判断前10行代码里面,是否有Last modified这个单词;
    152 "如果没有,需要添加作者信息;
    153 "如果有,只需要更新必要的信息即可;
    154   function TitleDet()
    155     let n=1
    156     "默认为添加
    157     while n < 10
    158         let line = getline(n)
    159         if line =~ '^  **s*S*修订时间:S*.*$'
    160         "更新注释信息
    161         call UpdateTitle()
    162             return
    163         endif
    164         let n = n + 1
    165     endwhile
    166     "添加注释信息
    167     call AddTitle()
    168   endfunction
    169 177 "======================================================添加注释==========================================================
    170 179 "======================================================编译运行==========================================================
    171 "通过键盘F9映射快速实现编译与运行
    172   map <F9> :call CompileRun()<cr>
    173   function CompileRun()
    174     exec "w"
    175     if &filetype == 'c'
    176     exec "!gcc -g  % -o %<"
    177     exec "!%<"
    178     elseif &filetype == 'cpp'
    179     exec "!g++ -g % -o %<"
    180     exec "!%<"
    181     elseif &filetype == 'java'
    182     exec "!javac %"
    183     exec "!java %<"
    184     else
    185     exec "echo not support filetype!"
    186     endif
    187   endfunction
    188 198 "======================================================编译运行==========================================================
    189 200 "######################################################自动补全##########################################################
    190 :inoremap ( ()<ESC>i
    191 :inoremap ) <c-r>=ClosePair(')')<CR>
    192 :inoremap } {}
    193 :inoremap { {<CR>}<ESC>O
    194 :inoremap } <c-r>=ClosePair('}')<CR>
    195 :inoremap [ []<ESC>i
    196 :inoremap ] <c-r>=ClosePair(']')<CR>
    197 :inoremap " ""<ESC>i
    198 ":inoremap ' ''<ESC>i
    199 function ClosePair(char)
    200     "if getline('.')[col('.') - 1 ] == a:char
    201     if getline('.') == a:char
    202     return "<Right>"
    203     else
    204     return a:char
    205     endif
    206 endfunction
    207 219 function CloseLPair(char)
    208     "if getline('.')[col('.') - 1 ] == a:char
    209     if getline('.') == a:char
    210     return "<Left>"
    211     else
    212     return a:char
    213     endif
    214 endfunction
    215 "######################################################自动补全##########################################################
    216 229 "====================================================##按键映射==========================================================
    217 map e ea
    218 "map e ea                               "移动到单词结尾时就自动进入插入模式
    219 "map + <C-w>+                           "增减窗口尺寸
    220 "map _ <C-w>-
    221 map + <C-w><                            "增减窗口尺寸
    222 map _ <C-w>>
    223 map <silent> <F2> :NERDTreeToggle<cr>               "tarbar functon list
    224 map <silent> <F3> :TagbarToggle<cr>             "header and implement file switch
    225 map <F4> :A<cr>                         "update index
    226 map <F5> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q<cr><cr>:cs kill cscope.out<cr>:!cscope -Rb<cr><cr>:cs add cscope.out<cr>        "switch display invisable ch    ar or not
    227 map <F6> :set list!<cr>:set list?<cr>               "highlight
    228 map <F7> ms:%s /<<C-R>=expand("<cword>")<CR>>//gn<cr>`    "swapfile list
    229 map <silent> <F8> :BufExplorer<CR>              "comment visual line
    230 nmap <C-[>g :cs find g <C-R>=expand("<cword>")<CR><CR>      "list the funcion called by this function
    231 nmap <C-[>d :cs find d <C-R>=expand("<cword>")<CR><CR>      "list the position where to call this word
    232 nmap <C-[>c :cs find c <C-R>=expand("<cword>")<CR><CR>      "search word in the project
    233 nmap <C-[>s :cs find s <C-R>=expand("<cword>")<CR><CR>      "search word in the project and the word can be in text
    234 nmap <C-[>t :cs find t <C-R>=expand("<cword>")<CR><CR>      "search word in the project and the word can be in text, support regex
    235 nmap <C-[>e :cs find e <C-R>=expand("<cword>")<CR><CR>      "list the file which filename is this word
    236 nmap <C-[>f :cs find f <C-R>=expand("<cfile>")<CR><CR>      "list the file include the file which filename is this word
    237 nmap <C-[>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>    "list the file which include this file
    238 nmap <C-[>I :cs find i <C-R>=expand("%:t")<CR><CR>
    239 "nnoremap j gj                          "自动换行时可在行中移动
    240 "nnoremap k gk
    241 nnoremap <C-h> <C-w>h                       "在分割的窗口间移动
    242 nnoremap <C-j> <C-w>j
    243 nnoremap <C-k> <C-w>k
    244 nnoremap <C-l> <C-w>l
    245 noremap <S-h> :bp<cr>                       "在buffer间移动
    246 noremap <S-l> :bn<cr>
    247 "用空格键来开关折叠
    248 nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
    249 vnoremap <silent> , :call NERDComment(1, "alignLeft")<cr>   "uncomment visual line
    250 vnoremap <silent> . :call NERDComment(1, "uncomment")<cr>   "show list if more tag
    251 265 if has("cscope")
    252     set nocsverb
    253     if filereadable("cscope.out")
    254         cs add cscope.out
    255     endif
    256 endif
    257 "======================================================按键映射==========================================================

    仅供参考!

  • 相关阅读:
    纯CSS3制作的“Ribbons”效果
    iOS 7.1的Safari为meta标签新增minimal-ui属性,在网页加载时隐藏地址栏与导航栏
    关于meta知多少
    mobile开发技巧
    大神给你分析HTTPS和HTTP的区别
    数据库之SQL语句分类
    pip安装第三方包失败
    django之分页
    django之发送电子邮件
    bug之needs to have a value for field "id" before this many-to-many relationship can be used.
  • 原文地址:https://www.cnblogs.com/binglmm/p/7810464.html
Copyright © 2020-2023  润新知