diff rc/vimrc @ 424:b86827ee1aae

Various vimrc cleanup.
author Edho Arief <edho@myconan.net>
date Sat, 29 Dec 2012 21:41:52 +0700
parents f4a29755dd01
children 5a347898e12f
line wrap: on
line diff
--- a/rc/vimrc	Fri Dec 28 09:09:28 2012 -0800
+++ b/rc/vimrc	Sat Dec 29 21:41:52 2012 +0700
@@ -1,19 +1,29 @@
-set showmode
-set showcmd
-set nomodeline
+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=
+set vb t_vb= " disables visual bell
 set ruler
-set nohls
 set nocompatible
-set backspace=2
+set backspace=2 " make backspace work like most other apps
 set esckeys
 set noerrorbells
-set ts=2
+set ts=8
+set sw=2
 set expandtab
 set title
-set list
+set hlsearch
+set ls=2 " always show status line
+set list listchars=tab:>-,trail:.,extends:>
+set number
+
+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>
@@ -24,6 +34,12 @@
 map <C-t><C-t> :NERDTreeToggle<cr>
 map <C-t><C-m> :NERDTreeMirror<cr>
 
+if has('let')
+  nmap _cs :let @/ = ''<cr>
+endif
+
+nmap _pa :set number! list!<cr>
+
 "autocmd VimEnter * NERDTree
 "autocmd BufEnter * NERDTreeMirror
 
@@ -37,18 +53,18 @@
 if has("autocmd")
   autocmd BufRead,BufNewFile supervisord.conf :set ft=dosini
   autocmd BufRead,BufNewFile Gemfile :set ft=ruby
-  autocmd BufRead,BufNewFile crontab.* :set noet ts=8 nolist
-  autocmd BufRead,BufNewFile crontab :set noet ts=8 nolist
-  autocmd BufRead,BufNewFile fstab :set noet ts=8 nolist
-  autocmd BufRead,BufNewFile .git/COMMIT_EDITMSG :set noet ts=8 nolist
-  autocmd BufRead,BufNewFile .gitconfig :set noet ts=8 nolist
-  autocmd BufRead,BufNewFile .git/config :set noet ts=8 nolist
-  autocmd BufRead,BufNewFile *.erb :set ft=eruby ts=2 et list
+  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 .gitconfig :set noet
+  autocmd BufRead,BufNewFile .git/config :set noet
+  autocmd BufRead,BufNewFile *.erb :set ft=eruby
   autocmd BufRead,BufNewFile *.scss :set ft=scss
   autocmd BufRead,BufNewFile *.coffee :set ft=coffee
 endif
 
-if has('function!')
+if has('function')
   "Restore cursor position
   set viminfo='10,\"100,:20,%,n~/.viminfo
   function! ResCur()
@@ -57,9 +73,39 @@
       return 1
     endif
   endfunction
-
   augroup resCur
     autocmd!
     autocmd BufWinEnter * call ResCur()
   augroup END
 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')
+    set titlestring=%t%(\ [%R%M]%)
+  endif
+endif