Skip to content

Instantly share code, notes, and snippets.

@j0k3r
Created November 10, 2010 17:21
Show Gist options
  • Save j0k3r/671165 to your computer and use it in GitHub Desktop.
Save j0k3r/671165 to your computer and use it in GitHub Desktop.
.vimrc
"--------------------------------------------------------------------
"
" NiLuJe's ViM Configuration File
"
" Highly inspired from Ciaran McCreesh's config
"
" (http://ciaranm.org/vimrc)
"
" $Id$
"
"--------------------------------------------------------------------
"---------------------------------
" Réglages
"---------------------------------
" Pas de compatibilité vi
set nocompatible
" Enable a nice big viminfo file
set viminfo='1000,f1,:1000,/1000
set history=500
" Make backspace delete lots of things
set backspace=indent,eol,start
" Show us the command we're typing
set showcmd
" Highlight matching parens
set showmatch
" Search options: incremental search, highlight search
set incsearch
set hlsearch
" Selective case insensitivity
autocmd BufEnter *
\ if &filetype == "cpp" |
\ set noignorecase noinfercase |
\ else |
\ set ignorecase infercase |
\ endif
" Show full tags when doing search completion
set showfulltag
" Speed up macros
set lazyredraw
" No annoying error noises
set noerrorbells
set visualbell t_vb=
autocmd GUIEnter * set visualbell t_vb=
" Try to show at least three lines and two columns of context when
" scrolling
set scrolloff=3
set sidescrolloff=2
" Use the cool tab complete menu
set wildmenu
set wildignore+=.svn,CVS,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,.lo,*~
set suffixes+=.in,.a
" Allow edit buffers to be hidden
set hidden
" 1 height windows
set winminheight=1
" Enable syntax highlighting
syntax on
" Set our fonts
set guifont=Bitstream\ Vera\ Sans\ Mono/9/-1/5/50/0/0/0/0/0
" Try to load a nice colourscheme
fun! LoadColourScheme(schemes)
let l:schemes = a:schemes . ":"
while l:schemes != ""
let l:scheme = strpart(l:schemes, 0, stridx(l:schemes, ":"))
let l:schemes = strpart(l:schemes, stridx(l:schemes, ":") + 1)
try
exec "colorscheme" l:scheme
break
catch
endtry
endwhile
endfun
if has('gui')
call LoadColourScheme("inkpot:night:rainbow_night:darkblue:elflord")
else
if &t_Co == 88 || &t_Co == 256
call LoadColourScheme("inkpot:elflord:darkblue")
else
call LoadColourScheme("elflord:darkblue")
endif
endif
" By default, go for an indent of 4
set shiftwidth=4
" Do clever indent things. Don't make a # force column zero.
set autoindent
set smartindent
inoremap # X<BS>#
" Enable folds
set foldenable
set foldmethod=indent
" Syntax when printing
set popt+=syntax:y
" Enable filetype settings
filetype on
filetype plugin on
filetype indent on
" Enable modelines
set modeline modelines=10
" Nice statusbar
set laststatus=2
set statusline=
set statusline+=%2*%-3.3n%0*\ " buffer number
set statusline+=%f\ " file name
set statusline+=%h%1*%m%r%w%0* " flags
set statusline+=\[%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{&encoding}, " encoding
set statusline+=%{&fileformat}] " file format
set statusline+=%= " right align
set statusline+=%2*0x%-8B\ " current char
set statusline+=%-14.(%l,%c%V%)\ %<%P " offset
" special statusbar for special windows
au FileType qf
\ if &buftype == "quickfix" |
\ setlocal statusline=%2*%-3.3n%0* |
\ setlocal statusline+=\ \[Compiler\ Messages\] |
\ setlocal statusline+=%=%2*\ %<%P |
\ endif
fun! <SID>FixMiniBufExplorerTitle()
if "-MiniBufExplorer-" == bufname("%")
setlocal statusline=%2*%-3.3n%0*
setlocal statusline+=\[Buffers\]
setlocal statusline+=%=%2*\ %<%P
endif
endfun
au BufWinEnter *
\ let oldwinnr=winnr() |
\ windo call <SID>FixMiniBufExplorerTitle() |
\ exec oldwinnr . " wincmd w"
" Nice window title
if has('title') && (has('gui_running') || &title)
set titlestring=
set titlestring+=%f\ " file name
set titlestring+=%h%m%r%w " flags
set titlestring+=\ -\ %{v:progname} " program name
endif
" Use a narrow number column.
setlocal numberwidth=3
" Better include path
set path+=src/
" set path+=/usr/lib/gcc/*/4.*/include/g++-v4/
" Includes AMX Mod X :)
" set path+=/home/niluje/SVN/svn.ak-team.com/Mirrors/AmxModX/plugins/include/
" Show tabs and trailing whitespace visually
if (&termencoding == "utf-8")
set list listchars=tab:»·,trail:·,extends:…,nbsp:‗
else
set list listchars=tab:>-,trail:.,extends:>,nbsp:_
endif
set fillchars=fold:-
" Nombre de colonnes
"set columns=80
" Autorise le passage d'une ligne à l'autre avec les flèches gauche et
" droite
set whichwrap=<,>,[,]
" Essaye de garder le curseur dans la même colonne quand on change de ligne
set nostartofline
" highlight current line
set cursorline
" highlight current column
set cursorcolumn
" Always show cursor position (Overriden by the custom statusline)
set ruler
" This is necessary to allow pasting from outside vim. It turns off auto stuff.
" You can tell you are in paste mode when the ruler is not visible
set pastetoggle=<F2>
" flag problematic whitespace (trailing and spaces before tabs)
" Note you get the same by doing let c_space_errors=1 but
" this rule really applys to everything.
highlight RedundantSpaces term=standout ctermbg=red guibg=red
match RedundantSpaces /\s\+$\| \+\ze\t/
" use :set list! to toggle visible whitespace on/off
" Disable wrapping
" set nowrap
"-----------------------------------------------------------------------
" completion
"-----------------------------------------------------------------------
" set dictionary=/usr/share/dict/words
" Correcteur d'orthographe. (Rouge tout partout !)
" setlocal spell spelllang=en
"-----------------------------------------------------------------------
" autocmds
"-----------------------------------------------------------------------
" enable line numbers.
setlocal number
setlocal foldcolumn=1
" Force active window to the top of the screen without losing its
" size.
fun! <SID>WindowToTop()
let l:h=winheight(0)
wincmd K
execute "resize" l:h
endfun
" Force active window to the bottom of the screen without losing its
" size.
fun! <SID>WindowToBottom()
let l:h=winheight(0)
wincmd J
execute "resize" l:h
endfun
" My autocmds
augroup niluje
autocmd!
" Always do a full syntax refresh
autocmd BufEnter * syntax sync fromstart
" For help files, move them to the top window and make <Return>
" behave like <C-]> (jump to tag)
autocmd FileType help :call <SID>WindowToTop()
autocmd FileType help nmap <buffer> <Return> <C-]>
" For svn-commit, don't create backups
autocmd BufRead svn-commit.tmp :setlocal nobackup
augroup END
" content creation
augroup content
autocmd!
autocmd BufNewFile *.rb 0put ='# !/usr/bin/ruby' |
\ norm G
autocmd BufNewFile *.sh 0put ='# !/bin/sh' |
\ norm G
augroup END
"-----------------------------------------------------------------------
" mappings
"-----------------------------------------------------------------------
nmap <silent> <S-Right> :bnext<CR>
" v_K is really really annoying
vmap K k
" Delete a buffer but keep layout
command! Kwbd enew|bw #
nmap <C-w>! :Kwbd<CR>
" quickfix things
nmap <Leader>cwc :cclose<CR>
nmap <Leader>cwo :botright copen 5<CR><C-w>p
nmap <Leader>cn :cnext<CR>
" Annoying default mappings
inoremap <S-Up> <C-o>gk
inoremap <S-Down> <C-o>gj
noremap <S-Up> gk
noremap <S-Down> gj
" Make <space> in normal mode go down a page rather than left a
" character
noremap <space> <C-f>
" Useful things from inside imode
inoremap <C-z>w <C-o>:w<CR>
inoremap <C-z>q <C-o>gq}<C-o>k<C-o>$
" Commonly used commands
nmap <silent> <F3> :silent nohlsearch<CR>
imap <silent> <F3> <C-o>:silent nohlsearch<CR>
nmap <F4> :Kwbd<CR>
nmap <F5> <C-w>c
" Insert a single char
noremap <Leader>i i<Space><Esc>r
" Split the line
nmap <Leader>n \i<CR>
" Pull the following line to the cursor position
noremap <Leader>J :s/\%#\(.*\)\n\(.*\)/\2\1<CR>
" In normal mode, jj escapes
inoremap jj <Esc>
" Kill line
noremap <C-k> "_dd
" Select everything
noremap <Leader>gg ggVG
" Reformat everything
noremap <Leader>gq gggqG
" Reformat paragraph
noremap <Leader>gp gqap
" Clear lines
noremap <Leader>clr :s/^.*$//<CR>:nohls<CR>
" Delete blank lines
noremap <Leader>dbl :g/^$/d<CR>:nohls<CR>
" Enclose each selected line with markers
noremap <Leader>enc :<C-w>execute
\ substitute(":'<,'>s/^.*/#&#/ \| :nohls", "#", input(">"), "g")<CR>
" Enable fancy % matching
runtime! macros/matchit.vim
" q: sucks
nmap q: :q
" set up some more useful digraphs
digraph ., 8230 " ellipsis (…)
" tab completion
function! CleverTab()
let col = col('.') - 1
if (&termencoding == "utf-8")
if !col || strpart(getline('.'), col-1, col) =~ '\s'
return "\<Tab>"
else
return "\<C-N>"
endif
else
if !col || getline('.')[col - 1] !~ '\k'
return "\<Tab>"
else
return "\<C-N>"
endif
endif
endfun
inoremap <Tab> <C-R>=CleverTab()<CR>
inoremap <S-Tab> <C-P>
"-----------------------------------------------------------------------
" special less.sh and man modes
"-----------------------------------------------------------------------
fun! <SID>check_pager_mode()
if exists("g:loaded_less") && g:loaded_less
" we're in vimpager / less.sh / man mode
set laststatus=0
set ruler
set foldmethod=manual
set foldlevel=99
set nolist
endif
endfun
autocmd VimEnter * :call <SID>check_pager_mode()
"-----------------------------------------------------------------------
" plugin / script / app settings
"-----------------------------------------------------------------------
" Perl specific options
let perl_include_pod=1
let perl_fold=1
let perl_fold_blocks=1
" Vim specific options
let g:vimsyntax_noerror=1
let g:vimembedscript=0
" c specific options
let g:c_gnu=1
let g:c_no_curly_error=1
" Settings for :TOhtml
let html_number_lines=1
let html_use_css=1
let use_xhtml=1
"-----------------------------------------------------------------------
" final commands
"-----------------------------------------------------------------------
" turn off any existing search
au VimEnter * nohls
"-----------------------------------------------------------------------
" vim: set shiftwidth=4 softtabstop=4 expandtab tw=72 :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment