Skip to content

Instantly share code, notes, and snippets.

@konobi
Created April 30, 2010 18:54
Show Gist options
  • Save konobi/385613 to your computer and use it in GitHub Desktop.
Save konobi/385613 to your computer and use it in GitHub Desktop.
set nocp " Use vim defaults, not vi ones
" set dg " Use digraphs
set fo+=r " Auto-format comments while typing
set com-=:% " '%' doesn't start comments
set hls " Highlight search pattern matches
set nojs " Join lines with only one space
set kp= " No external help system
set mps+=<:> " Make % work with <>
set mls=1 " Check one line for modelines
set nf-=octal " Ctrl-A doesn't increment octal numbers
set sb " Open new windows below the current one
set shm=a " Use the shortest messages
set sc " Show commands being typed
set scs " Smart case in search patterns when 'ignorecase' is on
set sm " Show matching brackets when typing
set su+=.class " Skip Java class files for filename completion
set su-=.h " but not C header files
set tw=0 " No automatic line wrap
set ul=200 " Maximum number of forgiveable mistakes
set ai si ts=8 sts=4 sw=4 noet " Default indent / tabs settings
set sbr=$ lcs=tab:!-,trail:~ wrap " List mode and non-text characters
set bk bdir=~/.tmp,.,/tmp,/var/tmp " Backup settings
set dir=~/.tmp,.,/tmp,/var/tmp " Swap file
if v:version >= 600
set nofen foldmethod=indent " Folding
set pa=.,/etc,~,, cd=,,.,~ " Where to search for files and paths
endif
set expandtab
" Custom status line display
set ls=2 " Always show status line
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 "
else
let &stl="%f %y%([%R%M]%)%{'!'[&ff=='".&ff."']}%{'$'[!&list]} (%{synIDattr(synID(line('.'),col('.'),0),'name')})%=#%n %l/%L,%c "
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
" Syntax highlighting settings and customizations
if has('syntax')
if has('gui_running') || $TERM =~ '^xterm'
set bg=light
else
set bg=dark
endif
hi Search ctermbg=yellow ctermfg=black
let perl_include_pod=1
let java_highlight_java_lang_ids=1
let java_highlight_debug=1
let java_allow_cpp_keywords=1
let is_bash=1
syntax on
if v:version >= 600
filetype plugin indent on
endif
endif
"
" Mappings
"
" Define this for plugins
let maplocalleader="_"
" Do a search on everything that matches the currently selected area
vmap * y:let@/=@"<CR>n
" Redefine Y to be more intuitive
nmap Y y$
" Easy-to-remember redefinitions of <C-E> and <C-Y> in gvim
if has('gui_running')
map <C-Down> <C-E>
map <C-Up> <C-Y>
imap <C-Down> <C-E>
imap <C-Up> <C-Y>
endif
" These mappings are useful on a french keyboard
"map ? ~
"map g? g~
"map ? ^
"map ? 0
"map ? %
"nmap <C-J> <C-]>
"imap <C-J> <C-]>
"
" France -> bin
" Break the current line after the cursor
nmap <F3> a<CR><Esc>
" Remove search pattern highlighting (because we have set hls previously)
nmap <F4> :noh<CR>
" Toggle list mode
nmap <F6> :se list!<CR>
" Append / insert current date
nmap _d "=strftime("%Y-%m-%d")<CR>p
nmap _D "=strftime("%Y-%m-%d")<CR>P
" Suppress all empty lines
nmap _em :g/^$/d<CR>
" Change directory to the one of the current file
nmap _h :lcd%:p:h<CR>
nmap _H :cd%:p:h<CR>
" if has('unix')
" " Open the current file / selected URL in Netscape / Mozilla / Galeon
" nmap _nn :!netscape -remote 'openFile(%:p)'<Bar><Bar>netscape file:%:p&<CR>
" vmap _nn "*y:!netscape -remote 'openURL(<C-R>*)'<Bar><Bar>netscape '<C-R>*'&<CR>
" endif
" Suppress all spaces at end/beginning of lines
nmap _s :%s/\s\+$//<CR>
nmap _S :%s/^\s\+//<CR>
" Convert file format to unix
nmap _ux :se ff=unix<CR>
" Execute current line as a vim command
nmap _xx "xyy:@x<CR>
"
" Functions
"
function Pod2Html()
!pod2html % > %:r.html ; rm -f *~~
endfunction
function Pod2Text()
!pod2text % > %:r.txt
endfunction
"
" Fix common typos and other abbreviations
"
iab varibale variable
iab varibales variables
iab pritn print
iab pirnt print
iab serach search
iab boolena boolean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment