Created
August 17, 2009 17:11
-
-
Save andersondias/169249 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Use Vim settings, rather then 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 | |
"store lots of :cmdline history | |
set history=1000 | |
set showcmd "show incomplete cmds down the bottom | |
set showmode "show current mode down the bottom | |
set incsearch "find the next match as we type the search | |
set hlsearch "hilight searches by default | |
set nowrap "dont wrap lines | |
set linebreak "wrap lines at convenient points | |
"statusline setup | |
set statusline=%f "tail of the filename | |
"display a warning if fileformat isnt unix | |
set statusline+=%#warningmsg# | |
set statusline+=%{&ff!='unix'?'['.&ff.']':''} | |
set statusline+=%* | |
"display a warning if file encoding isnt utf-8 | |
set statusline+=%#warningmsg# | |
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''} | |
set statusline+=%* | |
set statusline+=%h "help file flag | |
set statusline+=%y "filetype | |
set statusline+=%r "read only flag | |
set statusline+=%m "modified flag | |
"display a warning if &et is wrong, or we have mixed-indenting | |
set statusline+=%#error# | |
set statusline+=%{StatuslineTabWarning()} | |
set statusline+=%* | |
set statusline+=%{StatuslineTrailingSpaceWarning()} | |
"display a warning if &paste is set | |
set statusline+=%#error# | |
set statusline+=%{&paste?'[paste]':''} | |
set statusline+=%* | |
set statusline+=%= "left/right separator | |
set statusline+=%{StatuslineCurrentHighlight()}\ \ "current highlight | |
set statusline+=%c, "cursor column | |
set statusline+=%l/%L "cursor line/total lines | |
set statusline+=\ %P "percent through file | |
set laststatus=2 | |
"recalculate the trailing whitespace warning when idle, and after saving | |
autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning | |
"return '[\s]' if trailing white space is detected | |
"return '' otherwise | |
function! StatuslineTrailingSpaceWarning() | |
if !exists("b:statusline_trailing_space_warning") | |
if search('\s\+$', 'nw') != 0 | |
let b:statusline_trailing_space_warning = '[\s]' | |
else | |
let b:statusline_trailing_space_warning = '' | |
endif | |
endif | |
return b:statusline_trailing_space_warning | |
endfunction | |
"return the syntax highlight group under the cursor '' | |
function! StatuslineCurrentHighlight() | |
let name = synIDattr(synID(line('.'),col('.'),1),'name') | |
if name == '' | |
return '' | |
else | |
return '[' . name . ']' | |
endif | |
endfunction | |
"recalculate the tab warning flag when idle and after writing | |
autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning | |
"return '[&et]' if &et is set wrong | |
"return '[mixed-indenting]' if spaces and tabs are used to indent | |
"return an empty string if everything is fine | |
function! StatuslineTabWarning() | |
if !exists("b:statusline_tab_warning") | |
let tabs = search('^\t', 'nw') != 0 | |
let spaces = search('^ ', 'nw') != 0 | |
if tabs && spaces | |
let b:statusline_tab_warning = '[mixed-indenting]' | |
elseif (spaces && !&et) || (tabs && &et) | |
let b:statusline_tab_warning = '[&et]' | |
else | |
let b:statusline_tab_warning = '' | |
endif | |
endif | |
return b:statusline_tab_warning | |
endfunction | |
"indent settings | |
set shiftwidth=4 | |
set softtabstop=4 | |
set expandtab | |
set autoindent | |
"folding settings | |
set foldmethod=indent "fold based on indent | |
set foldnestmax=3 "deepest fold is 3 levels | |
set nofoldenable "dont fold by default | |
set wildmode=list:longest "make cmdline tab completion similar to bash | |
set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches | |
set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing | |
"display tabs and trailing spaces | |
set list | |
"set listchars=tab:▷⋅,trail:⋅,nbsp:⋅ | |
set formatoptions-=o "dont continue comments when pushing o/O | |
"vertical/horizontal scroll off settings | |
set scrolloff=3 | |
set sidescrolloff=7 | |
set sidescroll=1 | |
"load ftplugins and indent files | |
filetype plugin on | |
filetype indent on | |
"turn on syntax highlighting | |
syntax on | |
"some stuff to get the mouse going in term | |
set mouse=a | |
set ttymouse=xterm2 | |
"tell the term has 256 colors | |
set t_Co=256 | |
"hide buffers when not displayed | |
set hidden | |
set number | |
"dont load csapprox if we no gui support - silences an annoying warning | |
if !has("gui") | |
let g:CSApprox_loaded = 1 | |
else | |
if has("gui_gnome") | |
set term=gnome-256color | |
colorscheme vividchalk | |
else | |
set t_Co=256 | |
colorscheme vividchalk | |
set guitablabel=%M%t | |
set lines=40 | |
set columns=115 | |
endif | |
if has("gui_mac") || has("gui_macvim") | |
set guifont=Monaco:h16 | |
endif | |
if has("gui_win32") || has("gui_win32s") | |
set guifont=Consolas:h12 | |
endif | |
endif | |
nnoremap <silent> <Leader>p :ruby finder.rescan!<CR> :FuzzyFinderRemoveCache<CR> :NERDTreeToggle<CR> | |
inoremap <silent> <Leader>p :ruby finder.rescan!<CR> :FuzzyFinderRemoveCache<CR> :NERDTreeToggle<CR> | |
"make <c-l> clear the highlight as well as redraw | |
nnoremap <C-L> :nohls<CR><C-L> | |
inoremap <C-L> <C-O>:nohls<CR> | |
"map to bufexplorer | |
nnoremap <C-B> :FuzzyFinderBuffer<cr> | |
nnoremap <C-f> :bdelete<CR> | |
nnoremap <C-PageDown> :bp<CR> | |
"map to fuzzy finder text mate stylez | |
nnoremap <c-t> :FuzzyFinderTextMate<CR> | |
nnoremap <c-r> :ruby finder.rescan!<CR> :FuzzyFinderRemoveCache<CR> :exe ":echo 'rescan complete'"<CR> | |
inoremap <c-r> <ESC> :ruby finder.rescan!<CR> :FuzzyFinderRemoveCache<CR> :exe ":echo 'rescan complete'"<CR> | |
"map Q to something useful | |
noremap Q gq | |
"make Y consistent with C and D | |
nnoremap Y y$ | |
"visual search mappings | |
function! s:VSetSearch() | |
let temp = @@ | |
norm! gvy | |
let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') | |
let @@ = temp | |
endfunction | |
vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR> | |
vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR> | |
"jump to last cursor position when opening a file | |
"dont do it when writing a commit log entry | |
autocmd BufReadPost * call SetCursorPosition() | |
function! SetCursorPosition() | |
if &filetype !~ 'commit\c' | |
if line("'\"") > 0 && line("'\"") <= line("$") | |
exe "normal g`\"" | |
endif | |
end | |
endfunction | |
"define :HighlightExcessColumns command to highlight the offending parts of | |
"lines that are "too long". where "too long" is defined by &textwidth or an | |
"arg passed to the command | |
command! -nargs=? HighlightExcessColumns call s:HighlightExcessColumns('<args>') | |
function! s:HighlightExcessColumns(width) | |
let targetWidth = a:width != '' ? a:width : &textwidth | |
if targetWidth > 0 | |
exec 'match Todo /\%>' . (targetWidth+1) . 'v/' | |
else | |
echomsg "HighlightExcessColumns: set a &textwidth, or pass one in" | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment