Linux下vim配置文件

前言

需要注意的是 在使用之前 需要将 文件头部 global variables 部分 的变量名 根据自己的实际情况来设置一下 否则 闹出版权纠纷就大麻烦了

实际配置文件内容如下:

" FACIL: abodu notice once
" DESP: vim settings
" AUTHOR: Liu Dongguo
" ChgOn: 2015-04-14 07:00:42
" WebSite: http://www.github.com/jealdean/abodu
"
" GLOBAL-VARIABLES {{{1
let g:mapleader=‘;‘
let g:author=‘Liu Dongguo‘
let g:email=‘jealdean@outlook.com‘
let g:strVersion=‘1.0‘
let g:startyear=‘2007‘
let g:org=‘Abodu.com, Inc. All Rights Reserved‘

"TIPS-FOR-ALL {{{1
"notice:
" n: normal mode
" i: insert mode
" c: command mode
" v: view mode
" <c-KEY> : 的含义是 按下Ctrl 迅速再按下 ‘KEY‘

"TIP 1. 快速匹配括号 及 #if #else #endif
"n: % (first chang into normal mode,and press shift + 5)
"TIP 2. 快速查找当前光标位置处系统函数的 Man手册
"n: K (first chang into normal mode,and press shift + K)

"TIP 3. 快速跳转到相应的头文件处
"n: gf  (需要光标在头文件名字中)
"n: <ctrl-o> (跳回到原处)

"TIP 4.查看已经设置的vim的选项
"c: set [all]

"TIP 5.折叠
"关闭全部代码折叠功能
"n: zM
"打开/关闭 某一个折叠的代码块
"n:<space> (普通模式下按一次空格)

"GENERAL-SETTINGS {{{1
"common {{{2
syn on "开启语法高亮
set sm "设置匹配模式
set ai "自动对齐
set si "智能对齐
filetype on                    "开启类型检测
filetype plugin on             "为指定类型的文件加载plugin
filetype indent on             "
filetype plugin indent on      "可以使用智能补全
set completeopt=longest,menu   "关掉智能补全时的预览窗口
set path=.,include,../include,../../include,/usr/include  "当打开头文件的时候,自动搜索的路径
set path+=/usr/include/mysql  "add for mysql
set path+=/usr/src/kernel/include "add for linux kernel
"colors {{{2
set t_Co=256        "支持256色
colorscheme ron "主题
"colorscheme peaksea
" Encodings {{{2
set encoding=utf-8
set fenc=utf-8
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936,chinese
set ambiwidth=double
"folds {{{2
set foldenable         "开启折叠
set foldmethod=syntax  "默认标记方式
set foldcolumn=2       "折叠边宽
"set foldclose=all      "自动关闭折叠
set foldlevel=100      "默认不折叠
nnoremap <space> @=((foldclosed(line(‘.‘))<0)?‘zc‘:‘zo‘)<cr>
"tab {{{2
set nu     "显示行数
set list lcs=tab:\|\  "Tab 被替换显示成|
set noet   "不用空格扩展Tab"
set ts=4   "Tab的宽度,单位是一个空格宽
set sw=4
"status line {{{2
set laststatus=2  "总是显示状态栏
set stl=%F[%1*%M%*%n%R%H%w%m%h][%{strftime(\"%Y%m%d-%H:%M\")}][%l,%v,%p%%]\ %=\
set stl+=%0([%{&ft},%{&fileformat},%{&fileencoding}]%)\
"search and subst {{{2
set incsearch   "跳转到当前匹配位置
set hlsearch    "高亮显示搜索结果
set ignorecase  "不区分大小写
set gdefault    "替换时所有的行内匹配都被替换,而不是只有第一个
set autochdir   "自动设置目录为正在编辑的文件所在目录
set backspace=2 "设置退格键可用,等同于indent,eol,start
"others {{{2
set hidden      "没有保存的缓冲区可以自动被隐藏
set linebreak   "整词换行
set nobackup    "不自动备份
set nocp        "不兼容vi模式
set sc          "在状态栏显示正在输入的命令
set nowrap      "不自动换行
set vb t_vb=    "不提示错误响声
set wig=*.bak,*.o,*.e,*~   "tab键的自动完成现在会忽略这些后缀名的文件
set ttimeoutlen=100        ""

"PLUGINS {{{1
"csupport {{{2
"
let g:C_CFlags=‘-Wall -g -O0 -c -I/usr/include/mysql -I../../include‘
let g:C_Libs=‘-lm -lpthread -L/usr/lib64/mysql -lmysqlclient‘
let g:C_CplusFlags=g:C_CFlags
let g:C_CplusLibs=g:C_Libs
let g:C_TypeOfH=‘CPP‘
let g:C_InsertFileHeader =‘no‘
let g:C_BraceOnNewLine=‘yes‘
let g:C_MapLeader=‘;‘
let g:C_Comments=‘no‘
" echofunc{{{2
nmap efc <Esc>:!sudo ctags -f /usr/include/systags -I __THROW -I __attribute_pure__ -I __nonnull -I __attribute__ --file-scope=yes --langmap=c:+.h --languages=c,c++ --links=yes --c-kinds=+p --c++-kinds=+p --fields=+iaS --extra=+q /usr/include/* /usr/include/sys/* /usr/include/bits/* /usr/include/netinet/* /usr/include/arpa/* /usr/src/kernel/include/* /usr/include/mysql/*<CR>
set tags=/usr/include/systags
"
" taglist {{{2
let Tlist_Auto_Open=0
let Tlist_WinWidth=38
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Right_Window=0
let Tlist_Close_On_Select=1
let Tlist_File_Fold_Auto_Close = 0
let Tlist_GainFocus_On_ToggleOpen=1
let Tlist_Display_Prototype = 1
nmap tl :TlistToggle<cr>
" }}}
"windowmanager{{{2
let g:winManagerWidth=g:Tlist_WinWidth
let g:winManagerWindowLayout=‘TagList|FileExplorer‘
let g:wiw=60
nmap wm :WMToggle<cr>
"MAPPINGS {{{1
"basic mapping {{{2
"F1 - overrule Linux F1
map <silent> <F1> <esc>:exec "help ".expand("<cword>")<cr>
"F2 - call file explorer Ex
map  <silent> <F2>        :Explore<cr>
imap <silent> <F2>   <esc>:Explore<cr>
"F3 - remove trail white-space
map  <silent> <F3>        :%s/[ \r]\+$//g<cr>
imap <silent> <F3>   <esc>:%s/[ \r]\+$//g<cr>
"F4 - change to next buffer
map  <silent> <F4>        :bNext<cr>
imap <silent> <F4>   <esc>:bNext<cr>
"F10- 开启/关闭粘贴模式
set pastetoggle=<F10>
"insert space after some characters{{{2
inoremap , ,
inoremap =  =
inoremap -  -
inoremap +  +
inoremap <  <
inoremap >  >
inoremap --  --
inoremap ++  ++
inoremap >>  >>
inoremap <<  <<
inoremap &&  &&
inoremap ==  ==
inoremap !=  !=
inoremap +=  +=
inoremap <=  <=
inoremap >=  >=
inoremap /=  /=
inoremap *=  *=
"FUNCTIONS{{{1
"UD_CodeFormat {{{2
func! UD_CodeFormat()
  silent exec "ks| normal gg=G|‘s"
endf
"UD_AIAdd{{{2
func! UD_AIAdd()
  let n = 1
  while n < 5
    let line=getline(n)
    if (line =~ ‘^#!\/bin\/.*$‘ || line =~ ‘^\/.*$‘)
      return
    endif
    let n+=1
  endwhile
    "make some local variables
    let lCP=‘ Copyright (c) ‘.g:startyear.‘ - ‘.strftime(‘%Y‘).‘ ‘.g:org
    let lGL=‘************************************************************************‘
    let lName   =‘    NAME: ‘.expand(‘%:t‘)
    let lDesc   =‘    DESC: ‘
    let lAuthor =‘  AUTHOR: ‘.g:author.‘(‘.g:email.‘)‘
    let lVersion=‘ VERSION: ‘.g:strVersion
    let lCrTime =‘  CREATE: ‘.strftime(‘%Y-%m-%d %T‘)
    let lLuTime =‘  LUTIME: ‘.strftime(‘%Y-%m-%d %T‘)
    let lPF=‘ *‘
    let lGLS=‘/*‘
    let lGLE=‘ */‘
    let lExt=expand(‘%:p:e‘)
    if (lExt == ‘sh‘ || lExt == ‘pl‘ || lExt == ‘awk‘)
      let lPF=‘#‘
      let lGLE=‘#‘
      let lGLS=‘#!/bin/sh‘
      if lExt == ‘pl‘
        let lGLS=‘#!/bin/perl‘
      elseif lExt == ‘awk‘
        let lGLS=‘#!/bin/awk‘
      endif
    endif
    call append(0,[lGLS
    \,lPF.lGL
    \,lPF.lName,lPF.lDesc,lPF.lAuthor,lPF.lVersion,lPF.lCrTime,lPF.lLuTime
    \,lPF
    \,lPF.lCP
    \,lPF
    \,lPF.lGL
    \,lGLE])
endfunc
"UD_AIDetect{{{2
func! UD_AIDetect()
  let n=1
  let updated=0
  while n<10
    let line=getline(n)
    if (line =~ ‘.*NAME.*‘ || line =~ ‘.*FileName.*‘ || line =~ ‘.*Title.*‘)
      let newline=substitute(line,‘:.*$‘,‘: ‘.expand(‘%:t‘),‘g‘)
      call setline(n,newline)
      let updated = 1
    elseif ( line =~ ‘.*LUTIME.*‘ || line =~ ‘.*ChgOn.*‘ || line =~ ‘.*LastChangedTime.*‘ )
      let newline=substitute(line,‘:.*$‘,‘: ‘.strftime(‘%Y-%m-%d %T‘),‘g‘)
      call setline(n,newline)
      let updated = 1
    endif
    let n+=1
  endwhile

    if updated == 0
      call UD_AIAdd()
    endif
endfunc

"AUTOCMDS {{{1
if has("autocmd")
    au BufEnter * :lch %:p:h
    "au BufReadPost * if line("‘\"") > 0 && line("‘\"") <= line("$") | exe "normal! g`\"" | endif
    au InsertEnter * set cul cursorline cursorcolumn
    au InsertLeave * set nocul nocursorline nocursorcolumn

    au BufRead,BufNewFile make*,Make*,*mk* set ft=make
    au FileType c,cpp,java,make set noet nu fen  ts=4 sw=4 tw=80
    au BufRead,BufNewFile *vimrc set nu fen et ft=vim tw=80 fdm=marker fdl=100

    "au BufWritePre,FileWritePre,FileAppendPre *.sh,*.c,*.cpp,*.cc,*h,*.hpp :silent call UD_CodeFormat()
    au BufNewFile,BufNew *.sh,*.awk,*.pl,*.c,*.cpp,*.cc,*h,*.hpp :silent call UD_AIAdd()
    au BufWritePre,FileWritePre,FileAppendPre *vimrc,*.sh,*.awk,*.pl,*.c,*.cpp,*.cc,*h,*.hpp,README :silent call UD_AIDetect()
endif " has (autocmd)"

" CSUPPORT-HOTKEYS {{{1
"Legend:  (i) insert mode, (n) normal mode, (v) visual mode
"         [n] range
"
"-- Help ---------------------------------------------------------------
"
"     ;he       open an English dictionary for the    (n,i)
"               word under the cursor
"     ;hd       open the reference for the Doxygen    (n,i)
"               command under the cursor
"     ;hm       show manual for word under the cursor (n,i)
"     ;hp       show plugin help                      (n,i)
"
"-- Comments -----------------------------------------------------------
"
"  [n];cl       end-of-line comment                 (n,v,i)
"  [n];cj       adjust end-of-line comment(s)       (n,v,i)
"     ;cs       set end-of-line comment column      (n)
"  [n];c*       code -> comment /* */               (n,v,i)
"  [n];cc       code -> comment //                  (n,v,i)
"  [n];co       comment -> code                     (n,v,i)
"  [n];cn       toggle non-C comment                (n,v,i)
"     ;cfr      frame comment                       (n,i)
"     ;cfu      function comment                    (n,i)
"     ;cme      method description                  (n,i)
"     ;ccl      class description                   (n,i)
"     ;cfdi     file description (implementation)   (n,i)
"     ;cfdh     file description (header)           (n,i)
"     ;ccs      C/C++-file section  (tab. compl.)   (n,i)
"     ;chs      H-file section      (tab. compl.)   (n,i)
"     ;ckc      keyword comment     (tab. compl.)   (n,i)
"     ;csc      special comment     (tab. compl.)   (n,i)
"     ;cma      plugin macros       (tab. compl.)   (n,i)
"     ;cd       date                                (n,v,i)
"     ;ct       date ;& time                        (n,v,i)
"  [n];cx       toggle comments: C <--> C++         (n,v,i)
"
"-- Statements ---------------------------------------------------------
"
"     ;sd       do { } while                        (n,v,i)
"     ;sf       for                                 (n,i)
"     ;sfo      for { }                             (n,v,i)
"     ;si       if                                  (n,i)
"     ;sif      if { }                              (n,v,i)
"     ;sie      if else                             (n,v,i)
"     ;sife     if { } else { }                     (n,v,i)
"     ;se       else { }                            (n,v,i)
"     ;sw       while                               (n,i)
"     ;swh      while { }                           (n,v,i)
"     ;ss       switch                              (n,v,i)
"     ;sc       case                                (n,i)
"     ;sb       {}                                  (n,v,i)
"
"-- Idioms -------------------------------------------------------------
"
"     ;if       function                            (n,v,i)
"     ;isf      function static                     (n,v,i)
"     ;im       main()                              (n,v,i)
"     ;ie       enum   + typedef                    (n,i)
"     ;is       struct + typedef                    (n,i)
"     ;iu       union  + typedef                    (n,i)
"     ;isc      scanf()                             (n,i)
"     ;ipr      printf()                            (n,i)
"     ;ica      p=calloc()                          (n,i)
"     ;ima      p=malloc()                          (n,i)
"     ;ire      p=realloc()                         (n,i)
"     ;isi      sizeof()                            (n,v,i)
"     ;ias      assert()                            (n,v)
"     ;ii       open input file                     (n,i)
"     ;io       open output file                    (n,i)
"     ;ifsc     fscanf                              (n,i)
"     ;ifpr     fprintf                             (n,i)
"  [n];i0       for( x=0; x<n; x+=1 )               (n,v,i)
"  [n];in       for( x=n-1; x>=0; x-=1 )            (n,v,i)
"
"-- Preprocessor -------------------------------------------------------
"
"     ;pih      include standard library header     (n,i)
"     ;pg       #include <>  (global)               (n,i)
"     ;pl       #include ""  (local)                (n,i)
"     ;pd       #define                             (n,i)
"     ;pu       #undef                              (n,i)
"     ;pif      #if  #endif                         (n,v,i)
"     ;pie      #if  #else #endif                   (n,v,i)
"     ;pid      #ifdef #else #endif                 (n,v,i)
"     ;pin      #ifndef #else #endif                (n,v,i)
"     ;pind     #ifndef #def #endif                 (n,v,i)
"     ;pe       #error                              (n,i)
"     ;pl       #line                               (n,i)
"     ;pp       #pragma                             (n,i)
"     ;pw       #warning                            (n,i)
"     ;pi0      #if 0 #endif                        (n,v,i)
"     ;pr0      remove #if 0 #endif                 (n,i)
"
"-- Snippets -----------------------------------------------------------
"
"     ;nr       read code snippet                   (n,i)
"     ;nv       view code snippet (read-only)       (n,i)
"     ;nw       write code snippet                  (n,v,i)
"     ;ne       edit code snippet                   (n,i)
"
"  [n];nf       pick up function prototype          (n,v,i)
"  [n];np       pick up function prototype          (n,v,i)
"  [n];nm       pick up method prototype            (n,v,i)
"     ;ni       insert prototype(s)                 (n,i)
"     ;nc       clear  prototype(s)                 (n,i)
"     ;ns       show   prototype(s)                 (n,i)
"
"     ;ntl      edit local templates                (n,i)
"     ;ntr      reread templates                    (n,i)
"     ;njt      include jump tags                   (n,i)
"
"-- C++ ----------------------------------------------------------------
"
"     ;+ih      include C++ standard library header (n,i)
"     ;+ich     include C standard library header   (n,i)
"     ;+om      output manipulators                 (n,i)
"     ;+fb      ios flag bits                       (n,i)
"     ;+c       class                               (n,i)
"     ;+cn      class (using new)                   (n,i)
"     ;+tc      template class                      (n,i)
"     ;+tcn     template class (using new)          (n,i)
"     ;+ec      error class                         (n,i)
"     ;+tf      template function                   (n,i)
"     ;+tr      try ... catch                       (n,v,i)
"     ;+ca      catch                               (n,v,i)
"     ;+caa     catch(...)                          (n,v,i)
"     ;+ex      extern "C" {  }                     (n,v,i)
"     ;+oif     open input file                     (n,v,i)
"     ;+oof     open output file                    (n,v,i)
"     ;+uns     using namespace std;                (n,v,i)
"     ;+un      using namespace xxx;                (n,v,i)
"     ;+unb     namespace xxx {  }                  (n,v,i)
"     ;+na      namespace alias                     (n,v,i)
"     ;+rt      RTTI                                (n,v,i)
"
"     ;+ic      class implementation                (n,i)
"     ;+icn     class (using new) implementation    (n,i)
"     ;+im      method implementation               (n,i)
"     ;+ia      accessor implementation             (n,i)
"     ;+itc     template class implementation       (n,i)
"     ;+itcn    template class (using new) impl.    (n,i)
"     ;+itm     template method implementation      (n,i)
"     ;+ita     template accessor implementation    (n,i)
"     ;+ioi     operator >>                         (n,i)
"     ;+ioo     operator <<                         (n,i)
"
"-- Run ----------------------------------------------------------------
"
"    ;rc       save and compile                    (n,i)
"    ;rl       link                                (n,i)
"    ;rr       run                                 (n,i)
"    ;ra       set comand line arguments           (n,i)
"    ;rd       run debugger                        (n,i)
"
"    ;re       executable to run                   (n,i)
"
"    ;rp       run splint                          (n,i)
"    ;rpa      cmd. line arg. for splint           (n,i)
"    ;rcc      run cppcheck                        (n,i)
"    ;rccs     severity for cppcheck               (n,i)
"    ;rk       run CodeCheck (TM)                  (n,i)
"    ;rka      cmd. line arg. for CodeCheck (TM)   (n,i)
"    ;ri       run indent                          (n,v,i)
" [n];rh       hardcopy buffer                     (n,v,i)
"    ;rs       show plugin settings                (n,i)
"    ;rx       set xterm size                      (n, only Linux/UNIX & GUI)
"    ;ro       change output destination           (n,i)
" }}}

" /* vim: set ft=vim nu ts=4 sw=4 tw=80: */
时间: 2024-11-09 16:08:49

Linux下vim配置文件的相关文章

Linux下vim配置文件(无第三方插件版本)

vim_settings_without_plugins "============================================================== " Copyright (c) 2015 Abodu.com Inc. All Rights Reserved " " FNAME: vimrc_without_plugins " Brief: vim settings " Authr: jealdean &qu

mac 下vim 配置文件

" Configuration file for vim set modelines=0 " CVE-2007-2438 " Normally we use vim-extensions. If you want true vi-compatibility " remove change the following statements set nocompatible " Use Vim defaults instead of 100% vi compa

Linux 下vim 不能进行保存

折腾了一个中午,在终端输入  vim myProgram 然后编辑以下内容 #!/bin/bash clear echo "" echo "The Telephone Book" echo "" echo "1.Display A Telephone Number" ehco "2.Add A New Telephone Number" echo "" echo "Q Quit

linux下vim命令汇总

一. 进入vi的命令 vi filename : 打开或新建文件,并将光标置于第一行首 vi +n filename : 打开文件,并将光标置于第n行首 vi + filename : 打开文件,并将光标置于最后一行首 vi +/xxx filename:打开文件,并将光标置于第一个与xxx匹配的串处 vi -r filename : 在上次正用vi编辑时发生系统崩溃,恢复filename vi filename....filename :打开多个文件,依次进行编辑 二. 移动光标类命令 h :

linux下emacs配置文件

1:安装.在ubuntu下使用命令 sudo apt-get install emacs,即可,我使用的是ubuntu的10.04的版本,在里面使用了据说是163的2个源. 1.1:如何更新快速的源,在终端下输入:sudo gedit /etc/apt/sources.list 在里面添加这2个地址,我测试过速度相当的快. deb http://ubuntu.cn99.com/ubuntu/ karmic main restricted universe multiverse          

二十八、Linux下Vim工具常用命令

在linux下做开发,甚至是只做管理维护工作,也少不了Vim的使用.作为一个新手,我也是刚刚接触,本节将我日常使用或收集的Vim常用命令记录下来. 当然,直接在命令行上输入:vimtutor,就可以学习到Vim的所有命令了.Vim很强大,很多牛人在vim里集成很多插件什么的,但这里只介绍基本vim命令 移动命令 h "左 j "下 k "上 l "右 w "光标移动到下一个单词的首字符 a word forward b "光标移动到上一个单词的首

linux下bash配置文件詳解

linux下bash配置文件 1.bash的配置文件: 全局配置:/etc/profile, /etc/profile.d/*.sh, /etc/bashrc 个人配置:~/.bash_profile, ~/.bashrc profile类的文件: 设定环境变量 运行命令或脚本 bashrc类的文件: 设定本地变量 定义命令别名 2. 登录式shell读取配置文件順序如下: /etc/profile --> /etc/profile.d/*.sh --> ~/.bash_profile --&

linux下vim编辑器使用

VIM - Vi IMproved: vim是vi编辑器的升级版,是linux下标准的编辑器,具有程序编写能力,可以根据字体颜色辨别语法的正确性,方便程序的设计. 使用: # vim [OPTION]... FILE... +#:打开文件后,直接让光标处于第#行的行首 +/PATTERN:打开文件后,直接让光标处于第一个被PATTERN匹配到的行的行首 基本模式: 编辑模式(命令模式):打开文件的默认模式,可以上下左右键移动光标,复制粘贴删除数据 输入模式:编辑模式下按i,I,o,O,a,A等进

linux下vim命令详解

非常详细的介绍linux中vim的操作命令. 高级一些的编辑器,都会包含宏功能,vim当然不能缺少了,在vim中使用宏是非常方便的: :qx     开始记录宏,并将结果存入寄存器x q     退出记录模式 @x     播放记录在x寄存器中的宏命令 稍微解释一下,当在normal模式下输入:qx后,你对文本的所有编辑动作将会被记录下来,再次输入q即退出了记录模 式,然后输入@x对刚才记录下来的命令进行重复,此命令后可跟数字,表示要重复多少次,比如@x20,可以重复20次.这个在文本的批处理中