My ~/.vimrc until 20180717

" 07/17/2018 theta 1.0 notes

" 1.basic settings for coing in C/C++

" 2.ctags

" 3.omnicppcomplete

" 4.quickfix for make in vim

 

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

" from example vimrc

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

" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
  finish
endif

" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

if has("vms")
  set nobackup        " do not keep a backup file, use versions instead
else
  set backup        " keep a backup file (restore to previous version)
  set undofile        " keep an undo file (undo changes after closing)
endif
set history=50        " keep 50 lines of command line history
set ruler        " show the cursor position all the time
set showcmd        " display incomplete commands
set incsearch        " do incremental searching

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" Don't use Ex mode, use Q for formatting
map Q gq

" CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>

" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
  set mouse=a
endif

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

" Only do this part when compiled with support for autocommands.
if has("autocmd")
    au BufReadPost * if line("'\'") > 1 && line("'\'") <= line("$") | exe "normal! g'\"" | endif
  filetype plugin indent on

  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx
  au!

  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
    \ if line("'\"") >= 1 && line("'\"") <= line("$") |
    \   exe "normal! g`\"" |
    \ endif

  augroup END

endif

" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
  command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
          \ | wincmd p | diffthis
endif

if has('langmap') && exists('+langnoremap')
  " Prevent that the langmap option applies to characters that result from a
  " mapping.  If unset (default), this may break plugins (but it's backward
  " compatible).
  set langnoremap
endif


" Add optional packages.
"
" The matchit plugin makes the % command work better, but it is not backwards
" compatible.
packadd matchit

 

 

"===================================
" display settings
"===================================

" autoComplete brackets for programming language
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {}<ESC>i

if has("syntax")
    syntax on
endif
colorscheme ron

set history=1000
filetype on
set filetype=c
filetype indent on "针对不同的文件,采用不同的缩进方式
filetype plugin on "允许插件
filetype plugin indent on "启动自动补全

set autoread "文件修改之后自动读入

set nobackup
set noswapfile

"create undo file
set undolevels=1000
set undoreload=10000 "number of lines to save for undo
if v:version >= 730
    set undofile    "keep a persistent backup file
    set undodir = /tmp/vimundo/
endif

"set wildignore = *.swp,*.bak,*.pyc,*.class,.svn

set mouse=a

set ruler      "当前行列号
set showcmd    "状态栏:正在输入的命令
set showmode   "当前vim模式
set laststatus=2    "总是显示状态栏(powerline需要2行)
set number     "行号
set nowrap     "指定不折行
set showmatch  "代码匹配,包括括号匹配情况
set incsearch  "开启及时搜索(is)
set hls        "设置搜索高亮(hlsearch)
set ignorecase "搜索时忽略大小写
set smartcase  "搜索时尝试smart

set foldenable
set foldmethod=syntax "根据语法折叠

"设置C/C++方式自动对齐
set autoindent
set cindent
set smartindent
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s  "具体缩进方式

"tab宽度
set tabstop=4

"自动对齐空格数
set shiftwidth=4

set smarttab "backspace直接删除tab

set lbr "不在单词中间折行

set clipboard=unnamed  "允许vim与系统剪切板交互


"================================
" fileEncode Settings
"================================


set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1

set helplang=cn

set termencoding=utf-8

set ffs=unix,dos,mac

set formatoptions+=m
set formatoptions+=B

 

"================================
" Other Settings
"================================

"去掉有关i一致性模式
set nocompatible

set wildmenu    "增强模式中的命令行自动完成操作

"查找符号
nmap <leader>css :cs find s <C-R>=expand("<cword>")<CR><CR> :copen<CR><CR>
"查找定义
nmap <leader>csg :cs find g <C-R>=expand("<cword>")<CR><CR>
"查找被这个函数调用的函数
nmap <leader>csd :cs find d <C-R>=expand("<cword>")<CR><CR> :copen<CR><CR>
"查找调用这个函数的函数
nmap <leader>csc :cs find c <C-R>=expand("<cword>")<CR><CR> :copen<CR><CR>
"查找这个egrep匹配模式
nmap <leader>cse :cs find e <C-R>=expand("<cword>")<CR><CR> :copen<CR><CR>
"查找这个文件
nmap <leader>csf :cs find f <C-R>=expand("<cfile>")<CR><CR>
"查找include这个文件的文件
nmap <leader>csi :cs find i <C-R>=expand("<cfile>")<CR><CR> :copen<CR><CR>


"==========================
" ctags settings
"==========================

 

" 按下F5重新生成tag文件,并更新taglist
map <F5> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR> :TlistUpdate<CR>
imap <F5> <ESC>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR> :TlistUpdate<CR>
set tags=tags
set tags+=./tags "add current directory's generated tags file
" set tags+=/usr/include/systags "add new tags file(增加其他路径下的tags,在ctags -R
                    " 生成tags文件后,不要将tags移动到别的目录,否则ctrl+]时,会提示找不到源码文件)
set tags+=/usr/include/systags    "每次建立工程时自动建立该路径下的tags文件

 

"=============================
" OmniCppComplete
"=============================


" 按下F3自动补全代码,注意该映射语句后不能有其他字符,包括tab,否则乱码
imap <F3> <C-X><C-O>
" 按下F2根据头文件内关键字补全
imap <F2> <C-X><C-I>
set completeopt=menu,menuone   " 关掉智能补全时的预览窗口
let OmniCpp_MayCompleteDot = 1      " autocomplete with .
let OmniCpp_MayCompleteArrow = 1    " autocomplete with ->
let OmniCpp_MayCompleteScope = 1    " autocomplete with ::
let OmniCpp_SelectFirstItem = 2     " select first item (but don't insert)
let OmniCpp_NamespaceSearch = 2     " search namespaces in this and included files
let OmniCpp_ShowPrototypeInAbbr = 1 "show function prototype in popup window
let OmniCpp_GlobalScopeSearch=1     "enable the global scope search
let OmniCpp_DisplayMode=1           "Class scope completion mode: always show all members
let OmniCpp_DefaultNamespaces=["std"]
let OmniCpp_ShowScopeInAbbr=1       "show scope in abbreviation and remove the last column
let OmniCpp_ShowAccess=1

set tags+=/usr/include/omnitags

 

"================================
"      quickfix
"================================


"按下F6makeclean
map <F6> :make clean<CR><CR><CR>
"F7 make
map <F7> :make<CR><CR><CR> :copen<CR>
"F8 光标移到上一个错误所在行
map <F8> :cp<CR>
"F9 光标到下一个错误所在行
map <F9> :cn<CR><CR>
"以上在插入模式下也能用
imap <F6> <ESC>:make clean<CR><CR><CR>
imap <F7> <ESC>:make<CR><CR><CR> :copen<CR><CR>
imap <F8> <ESC>:cp<CR>
imap <F9> <ESC>:cn<CR>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值