view rc/vimrc @ 531:d6e08a057094

Updates to vim settings. - clear search key - smarter search - visual navigation - misc comments
author edogawaconan <me@myconan.net>
date Mon, 03 Nov 2014 23:22:59 +0900
parents de3ff51840a3
children 70d4fb4f7d9f
line wrap: on
line source

set nocompatible
set showmode " shows mode insert/replace/visual
set showcmd " shows last command on screen
set nomodeline " disallow automatic vim command execution on arbitrary file
set autoindent
set lazyredraw
set vb t_vb= " disables visual bell
set ruler
set backspace=2 " make backspace work like most other apps
set esckeys
set noerrorbells
set ts=8
set sw=2
set expandtab
set title
set incsearch
set ignorecase
set smartcase
set hlsearch
set ls=2 " always show status line
set list listchars=tab:>-,trail:.,extends:>
set number

" http://stackoverflow.com/questions/14635295/vim-takes-a-very-long-time-to-start-up
set clipboard=exclude:.*

if has('call')
  call pathogen#infect()
endif
if has('filetype')
  filetype plugin indent on
endif

map <C-t><up> :tabr<cr>
map <C-t><down> :tabl<cr>
map <C-t><left> :tabp<cr>
map <C-t><right> :tabn<cr>
map <C-t>p :tabp<cr>
map <C-t>n :tabn<cr>
map <C-t><C-t> :NERDTreeToggle<cr>
map <C-t><C-m> :NERDTreeMirror<cr>

" clears out highlight
nmap <leader>c :nohlsearch<cr>

" toggles paste mode
nmap <leader>p :set paste!<cr>

" removes prefix for windows copypasta
nmap _pa :set number! list!<cr>

" format JSON
map <leader>j <esc>:%!python -m json.tool<cr>

" visual navigation instead of logical
nmap j gj
nmap k gk

"autocmd VimEnter * NERDTree
"autocmd BufEnter * NERDTreeMirror

if has('syntax')
  syntax on
  set foldmethod=syntax
  set nofoldenable
  set background=dark
  set t_Co=256
  colorscheme base16-default
endif

if has("autocmd")
  augroup json_autocmd
    autocmd!
    autocmd FileType json set autoindent
    autocmd FileType json set formatoptions=tcq2l
    autocmd FileType json set textwidth=78 shiftwidth=2
    autocmd FileType json set softtabstop=2 tabstop=8
    autocmd FileType json set expandtab
    autocmd FileType json set foldmethod=syntax
  augroup END
  au! BufRead,BufNewFile *.json set filetype=json
  autocmd BufRead,BufNewFile supervisord.conf :set ft=dosini
  autocmd BufRead,BufNewFile Gemfile :set ft=ruby
  autocmd BufRead,BufNewFile config.ru :set ft=ruby
  autocmd BufRead,BufNewFile crontab.* :set noet
  autocmd BufRead,BufNewFile crontab :set noet
  autocmd BufRead,BufNewFile fstab :set noet
  autocmd BufRead,BufNewFile */.git/COMMIT_EDITMSG :set noet
  autocmd BufRead,BufNewFile .git/COMMIT_EDITMSG :set noet
  autocmd BufRead,BufNewFile .gitconfig :set noet
  autocmd BufRead,BufNewFile .git/config :set noet
  autocmd BufRead,BufNewFile *.coffee :set ft=coffee
  autocmd BufRead,BufNewFile *.erb :set ft=eruby
  autocmd BufRead,BufNewFile *.scss :set ft=scss
  autocmd BufRead,BufNewFile *.slim :set ft=slim
endif

if has('autocmd')
  "Restore cursor position
  set viminfo='10,\"100,:20,%,n~/.viminfo
  function! ResCur()
    if line("'\"") <= line("$")
      normal! g`"
      return 1
    endif
  endfunction
  augroup resCur
    autocmd!
    autocmd BufWinEnter * call ResCur()
  augroup END
  autocmd BufWinEnter */.git/COMMIT_EDITMSG exe "normal! gg"
  autocmd BufWinEnter .git/COMMIT_EDITMSG exe "normal! gg"
endif

if has('statusline')
  " Status line detail:
  " %f     file path
  " %y     file type between braces (if defined)
  " %([%R%M]%)   read-only, modified and modifiable flags between braces
  " %{'!'[&ff=='default_file_format']}
  "        shows a '!' if the file format is not the platform
  "        default
  " %{'$'[!&list]}  shows a '*' if in list mode
  " %{'~'[&pm=='']} shows a '~' if in patchmode
  " (%{synIDattr(synID(line('.'),col('.'),0),'name')})
  "        only for debug : display the current syntax item name
  " %=     right-align following items
  " #%n    buffer number
  " %l/%L,%c%V   line number, total number of lines, and column number
  function SetStatusLineStyle()
    if &stl == '' || &stl =~ 'synID'
      let &stl="%f %y%([%R%M]%)%{'!'[&ff=='".&ff."']}%{'$'[!&list]}%{'~'[&pm=='']}%=#%n %l/%L,%c%V "
    else
      let &stl="%f %y%([%R%M]%)%{'!'[&ff=='".&ff."']}%{'$'[!&list]} (%{synIDattr(synID(line('.'),col('.'),0),'name')})%=#%n %l/%L,%c%V "
    endif
  endfunc
  " Switch between the normal and vim-debug modes in the status line
  nmap _ds :call SetStatusLineStyle()<CR>
  call SetStatusLineStyle()
  " Window title
  if has('title')
    if &term == "screen"
      set t_ts=]0;
      set t_fs=
    endif
    set title
    let &titlestring = $user
  endif
endif