dotfiles

config files for my linux setup
git clone git://edryd.org/dotfiles
Log | Files | Refs | README

vimrc.vim (6664B)


      1 " basic{{{1
      2 syntax on
      3 set autoindent                  " I hope you know what this does
      4 set autowrite                   " automatically write before running commands that need it to be written
      5 set nohlsearch                  " turn off highlighting of searches
      6 set ignorecase                  " make search non case sensitive
      7 set incsearch                   " show the search result before you finish typing
      8 set noshowmode                  " turn off '--INSERT--' at bottom of screen
      9 set nowrap                      " do not wrap text to newline when it gets to the end of the screen
     10 set shiftround                  " make indents always be at a multiple of the tab width
     11 set showcmd                     " show normal mode commands that you are typing
     12 set nocursorline
     13 set showmatch                   " when a bracket is inserted, briefly highlight the matching one.
     14 set smartcase                   " allow you to search with more charters
     15 set hidden                      " keep buffers loaded when not visible
     16 set splitbelow                  " create new splits under current window
     17 set splitright                  " create new vertical splits to the right
     18 set timeout                     " set timeout for mappings
     19 set notitle                     " stop Vim from setting the terminal's title
     20 set ttyfast                     " makes Vim faster
     21 set novisualbell                " disable screen flashes for error
     22 set backspace=2                 " turn on backspace
     23 set completeopt-=preview        " disable pop-up when using Neocomplete
     24 " set cryptmethod=blowfish        " change the way Vim encrypts files to blowfish from zip
     25 set formatoptions+=w            " when text get over the number set by `set textwidth`, wrap it to next line
     26 set foldmethod=marker           " set the folding method to use three { to start and three } to end
     27 set laststatus=2                " always turn on status line
     28 set modelines=5                 " number of lines down Vim checks for set commands
     29 set mouse=a                     " turn on the mouse
     30 set nrformats=octal,hex,alpha   " allow you to ctrl-a/ctrl-x to increase/decrease letters and numbers
     31 set scrolloff=7                 " make Vim have 7 lines below cursor when moving down
     32 set t_ut=                       " needed if using Vim inside of tmux
     33 set textwidth=98                " wrap lines which exceed 100 charters long
     34 set ttimeoutlen=50              " change wait time for `timeout`
     35 set spell spelllang=en_us       " set language for spell check to United States
     36 set clipboard=unnamedplus       " Vim yanks go to OS's clipboard as well
     37                                 " remove 'plus' if not on Linux
     38 
     39 " set up menu stuff
     40 set wildmenu
     41 set wildmode=list,longest,full
     42 
     43 " make line numbers go 1,2,3,4...
     44 set number
     45 " make the line your cursor is on 0
     46 " set relativenumber
     47 
     48 " extra chars like the end of line one and when text raps to next line
     49 set list
     50 set listchars=tab:\|\ ,eol:¬,extends:❯,precedes:❮
     51 
     52 " make Vim's clipboard the same as OS's clipboard
     53 let g:clipbrdDefaultReg = '+'
     54 
     55 if has("autocmd")
     56   " make Vim save every time it leaves insert mode
     57   autocmd InsertLeave * if &mod && expand('%')!=''|write|endif
     58 
     59   " save line number line when reopening file
     60   autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
     61   " don't for git commit file
     62   autocmd FileType gitcommit normal gg
     63 
     64   " remove trailing whitespace
     65   autocmd BufWritePre * %s/\s\+$//e
     66 endif
     67 
     68 " highlighting{{{1
     69 colorscheme zim
     70 
     71 " highlight the 100th column so you know when your line is to long
     72 call matchadd('Error', '\%100v', 100)
     73 
     74 au BufRead,BufNewFile *.md  set filetype=markdown
     75 au BufRead,BufNewFile *bash_profile* set filetype=sh
     76 au BufRead,BufNewFile *tmux.conf*    set filetype=sh
     77 au BufRead,BufNewFile *conkyrc*      set filetype=sh
     78 au BufRead,BufNewFile *gitconfig*    set filetype=gitconfig
     79 au BufRead,BufNewFile TODO           set filetype=markdown
     80 
     81 " spell check
     82 hi SpellBad ctermfg=red cterm=underline
     83 if version >= 700
     84   set spl=en spell
     85   set nospell
     86 endif
     87 
     88 " fix highlighting of special symbols
     89 function! C_Syntax()
     90   syntax match _Operator "[-+&|<>=!\*~.,:%&^?]"
     91   syntax match _Operator "/ \|/="
     92   syntax match _Semicolon "[;]"
     93   hi link _Operator Operator
     94   hi _Semicolon ctermfg=red
     95   set sw=8
     96   set ts=8
     97   set noexpandtab
     98 endfunction
     99 autocmd! BufRead,BufNewFile,BufEnter *.{c,cpp,h,hpp,} call C_Syntax()
    100 
    101 " status line{{{1
    102 function! InsertStatuslineColor(mode)
    103   if a:mode == 'i'
    104     hi statusline ctermfg=4   ctermbg=15
    105     hi SLgreen    ctermfg=0 ctermbg=4
    106     hi SLblue     ctermfg=0 ctermbg=4
    107     hi SLcyan     ctermfg=0 ctermbg=4
    108   elseif a:mode == 'r'
    109     hi statusline ctermfg=9 ctermbg=15
    110     hi SLgreen    ctermfg=0 ctermbg=9
    111     hi SLblue     ctermfg=0 ctermbg=9
    112     hi SLcyan     ctermfg=0 ctermbg=9
    113   else
    114     hi statusline ctermfg=0 ctermbg=15
    115   endif
    116 endfunction
    117 
    118 au InsertEnter * call InsertStatuslineColor(v:insertmode)
    119 au InsertLeave * hi statusline ctermfg=0 ctermbg=15
    120 au InsertLeave * hi SLgreen    ctermfg=2 ctermbg=0
    121 au InsertLeave * hi SLblue     ctermfg=4 ctermbg=0
    122 au InsertLeave * hi SLcyan     ctermfg=6 ctermbg=0
    123 
    124 hi statusline ctermfg=0 ctermbg=15
    125 hi SLgreen    ctermfg=2 ctermbg=0
    126 hi SLblue     ctermfg=4 ctermbg=0
    127 hi SLcyan     ctermfg=6 ctermbg=0
    128 
    129 set statusline=%#SLblue#%f       " file name
    130 set statusline+=%#SLgreen#\ %Y   " filetype
    131 set statusline+=%#SLcyan#\ %M    " modified flag
    132 " set statusline+=\ %{g:Catium()}
    133 
    134 set statusline+=\ %=             " move to right side
    135 
    136 set statusline+=%#SLcyan#%p%%    " percent of file
    137 set statusline+=%#SLgreen#\ %v   " column
    138 set statusline+=%#SLblue#\ %l/%L " current line/total lines
    139 " set statusline+=%#ErrorMsg#%{SyntasticStatuslineFlag()} " Syntastic Error
    140 
    141 " mapping{{{1
    142 " make jj typed quickly while in insert mode switch to normal mode :D
    143 inoremap jj <Esc>
    144 
    145 " make ctrl+c completely like ESC
    146 inoremap <C-c> <Esc><Esc>
    147 
    148 " extend ESC to also clear search highlight
    149 nnoremap <silent> <ESC> :noh<CR>
    150 nnoremap <ESC>[ <ESC>[
    151 
    152 " ZZ is save and quit and ZQ is just quit, so...
    153 " make ZS to save without closing
    154 nnoremap ZS :w<CR>
    155 " make ZA save and quit all windows
    156 nnoremap ZA :wqall<CR>
    157 
    158 " C changes until end of line and D deletes until end of line, so why not Y?
    159 noremap Y y$
    160 
    161 " repeat colon commands
    162 nnoremap Q :<Up><CR>
    163 
    164 " keep selected area when indenting
    165 vnoremap > >gv
    166 vnoremap < <gv
    167 
    168 " easily change buffers
    169 nnoremap <C-H> :bprev<CR>
    170 nnoremap <C-L> :bnext<CR>
    171 
    172 " improve up and down shortcuts
    173 nnoremap <C-J> <C-D>
    174 nnoremap <C-K> <C-U>
    175 
    176 nnoremap <silent> <leader>m :silent! make<CR>
    177 nnoremap <silent> <leader>c :!ctags -R .<CR>
    178 
    179 " auto complete C comments
    180 inoremap /*  /*  */<Left><Left><Left>