Skip to content

Instantly share code, notes, and snippets.

@zoqaeski
Created December 28, 2009 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoqaeski/264580 to your computer and use it in GitHub Desktop.
Save zoqaeski/264580 to your computer and use it in GitHub Desktop.
"
" MAIN CUSTOMIZATION FILE
"
""""""""""""""""""""""""""""""""
"
" DISPLAY
"
""""""""""""""""""""""""""""""""
" We DO NOT want Vi compatibility
set nocompatible
" Enable loading filetype and indentation plugins
filetype plugin on
filetype indent on
" Turn syntax highlighting on
syntax on
" Welcome to the 21st century: UTF-8 character encoding
set encoding=utf-8
" faster macros
set lazyredraw
" we like security
set nomodeline
" STOP UNDERLINING THE CURRENT LINE!!!
set nocursorline
" abbrev. of messages (avoids 'hit enter')
set shortmess+=atI
" display the current mode
set showmode
" min num of lines to keep above/below the cursor
set scrolloff=4
" show line numbers
set number
" My own preferred colour scheme; I'm looking for a better one
colorscheme zxtc
if has('cmdline_info')
" show the ruler
set ruler
" a ruler on steroids
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%)
" show partial commands in status line and selected characters/lines in
" visual mode
set showcmd
endif
if has('statusline')
" always show a status line
set laststatus=2
" a statusline, also on steroids
"set statusline=%<%f\ %=\:\b%n\[%{strlen(&ft)?&ft:'none'}/%{&encoding}/%{&fileformat}]%m%r%w\ %l,%c%V\ %P
set statusline=%<%f\ %m%r%w\ %=\:\b%n\[%{strlen(&ft)?&ft:'none'}/%{&fileformat}]\ %l,%c%V\ %P
endif
" Remember up to 100 'colon' commmands and search patterns
set history=100
" Hide buffers
set hidden
" Write contents of the file, if it has been modified, on buffer exit
"set autowrite
""""""""""""""""""""""""""""""""
"
" gvim- (here instead of .gvimrc)
"
""""""""""""""""""""""""""""""""
if has('gui_running')
set guioptions=acgi
"set guioptions=acgir
" I turned off the scrollbars
set guioptions-=rRlL
" This adds GTK+ tabs... not sure if I want it or not
"set guioptions+=e
set guioptions-=tTm
set showtabline=2
" STOP UNDERLINING THE CURRENT LINE!!!
set nocursorline
set columns=144 lines=40
endif
""""""""""""""""""""""""""""""""
"
" EDITING
"
""""""""""""""""""""""""""""""""
" Backspace for dummies
set backspace=indent,eol,start
" Show matching brackets/parenthesis
set showmatch
" Command <Tab> completion, list matches and complete the longest common
" part, then, cycle through the matches
set wildmode=list:longest,full
" Wrap long lines
set wrap
" The text width
set textwidth=0
set linebreak
" Indent at the same level of the previous line
set autoindent
" Use indents of 4 spaces
set shiftwidth=4
" Use 4 spaces for <Tab> and :retab
set tabstop=4
set softtabstop=4
set noexpandtab
" Round indent to multiple of 'shiftwidth' for > and < commands
set shiftround
" When a bracket is inserted, briefly jump to a matching one
set noshowmatch
" Jump to matching bracket for 2/10th of a second (works with showmatch)
" This got rather annoying
"set matchtime=
" basic formatting of text and comments
"set formatoptions+=tcq
" match, to be used with %
set matchpairs+=<:>
" ignore these file types when opening
set wildignore=*.pyc,*.o,*.obj,*.swp
" Show (partial) commands (or size of selection in Visual mode) in the status line
set showcmd
" Allow lots of tab pages -- 100 should be plenty
set tpm=100
" Always make split windows equal
set noequalalways
" Write swap file to disk after every 50 characters
set updatecount=100
""""""""""""""""""""""""""""""""
"
" SEARCH
"
""""""""""""""""""""""""""""""""
" Incremental searching
set incsearch
" Do not highlight search results
set nohlsearch
" Ignore case
set ignorecase
set smartcase
""""""""""""""""""""""""""""""""
"
" MAPPINGS
"
""""""""""""""""""""""""""""""""
" I'm not sure if this does what it should, so I'll leave it here until it no longer serves its purpose
"imap <C-space> <Plug>IMAP_JumpForward
" Map leader
let mapleader = ","
" Switch between windows quickly -- these didn't quite work so I disabled them for the time being
"nnoremap <C-J> <C-W>j
"nnoremap <C-K> <C-W>k
"nnoremap <C-H> <C-W>h
"nnoremap <C-L> <C-W>l
" Switch between buffers quickly
nnoremap gb :bnext<CR>
nnoremap gB :bprevious<CR>
" Fix for normal h j k l mappings -- this always moves virtual lines -- I know some purists will think I'm weird, but I don't care.
map j gj
map k gk
map H ^
map L $
" Page down with <Space>
nmap <Space> <PageDown>
" Visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
" Change to directory of current file
map <Leader>%cd :cd %:p:h<CR>
" Quit write/quit
nnoremap <Leader>w :w<CR>
nnoremap <Leader>q :q!<CR>
" Destroy things
noremap <Leader>c "_c
noremap <Leader>C "_C
noremap <Leader>d "_d
noremap <Leader>D "_D
noremap <Leader>s "_s
noremap <Leader>S "_S
noremap <Leader>x "_x
" Insert blank lines
noremap <Leader>o o<Esc>k
noremap <Leader>O O<Esc>j
" Show hidden characters
set listchars=tab:>-,trail:·,eol:$
nmap <silent> <Leader>h :set nolist!<CR>
" Vi-style editing in the command-line : NOICE
" This apparently make things much easier
noremap <Leader>: q:
noremap <Leader>/ q/
noremap <Leader>? q?
" Is this quicker?
noremap :: q:
noremap // q/
noremap ?? q?
" Yank Ring mappings
"noremap Y y$
nnoremap Y :<C-U>YRYankCount 'y$'<CR>
noremap <Leader>y :YRShow<CR>
" TODO: Add a TaskList Toggle perhaps?
" Delete word with Backspace
imap <S-BS> <Esc>bdwa
nmap <S-BS> <Esc>bdwa
" Delete and backspace in insert mode
inoremap <C-H> <BS>
inoremap <C-D> <Del>
" Use F10 to toggle 'paste' mode... whatever that is
set pastetoggle=<F10>
nmap <Leader>p :set invpaste<CR>
nmap <Leader>P :set paste<CR>I
" Open filename under cursor in a new window (use current file's working directory)
nmap gf :new %:p:h/<cfile><CR>
""""""""""""""""""""""""""""""""
"
" FILE TYPES
"
""""""""""""""""""""""""""""""""
"autocmd FileType c,cpp call <SID>cstuff()
"function! <SID>cstuff()
" set cindent
" set formatoptions+=croql
" set formatoptions-=t
" set omnifunc=ccomplete#Complete
"endfunction
"autocmd filetype python call <sid>pystuff()
"function! <sid>pystuff()
" set shiftwidth=4
" set tabstop=4
" set softtabstop=4
" set noexpandtab
" set autoindent
" set foldmethod=indent
" set foldlevel=999999
" set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,with
" set omnifunc=pythoncomplete#Complete
"endfunction
"autocmd filetype tex,cls call <sid>texstuff()
"function! <sid>texstuff()
" set shiftwidth=2
" set tabstop=2
" set softtabstop=2
" set textwidth=116
" set noexpandtab
"endfunction
" ignore miscellaneous latex stuff
"set wildignore=*.log,*.aux,*.dvi,*.aut,*.aux,*.bbl,*.blg,*.dvi,*.fff,*.log,*.out,*.pdf,*.ps,*.toc,*.ttt
" optional: starting with vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" the following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
let g:tex_gotoerror=0
au BufWritePost *.tex silent call Tex_CompileLatex()
" Nifty XML tricks
"autocmd filetype xml '[,']!xsltproc ~/.vim/ftplugin/indent.xsl %
"autocmd FileType xml call <sid>xmlstuff()
"function! <sid>xmlstuff()
" "set omnifunc=xmlcomplete#CompleteTags
" "set equalprg=xmllint --format -
" set shiftwidth=4
" set tabstop=4
" set softtabstop=4
" set noexpandtab
" set shiftround
" let b:matchwords="<.\{-}>"
" set noexpandtab
"endfunction
" HTML
"autocmd filetype html call <sid>htmlstuff()
"function! <sid>htmlstuff()
" set omnifunc=htmlcomplete#CompleteTags
" "set textwidth=120
" set shiftwidth=4
" set tabstop=4
" set softtabstop=4
" set shiftround
" set noexpandtab
"endfunction
" Lisp
"autocmd filetype lisp call <sid>lispstuff()
"function! <sid>lispstuff()
" set shiftwidth=2
" set tabstop=2
" set softtabstop=2
" set expandtab
" set autoindent
"endfunction
" Haskell
let g:haddock_browser="firefox"
"autocmd filetype haskell call <sid>haskellstuff()
"function! <sid>haskellstuff()
" set shiftwidth=4
" set tabstop=4
" set softtabstop=4
" set expandtab
" set autoindent
"endfunction
" load manual pages
"runtime ftplugin/man.vim
"let $pager=''
"let $manpager=''
" Omni-completion?
"autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
"autocmd FileType css set omnifunc=csscomplete#CompleteCSS
"autocmd FileType php set omnifunc=phpcomplete#CompletePHP
" Java
"autocmd FileType java call <sid>javastuff()
"function! <sid>javastuff()
" set shiftwidth=4
" set tabstop=4
" set softtabstop=4
" set noexpandtab
" set autoindent
" set omnifunc=javacomplete#Complete
" set completefunc=javacomplete#CompleteParamsInfo
" inoremap <C-X><C-U> <C-X><C-U><C-P>
" inoremap <C-S-Space> <C-X><C-U><C-P>
" "set include=^#\s*import
" "set includeexpr=substitute(v:fname,'\\.','/','g')
" "set complete=i,],.,b,w,t,k,.
" "set dictionary=~/.vimKeywords
" "set tags=~/programming/tags/java
" " Automatically load getters and setters. Bit of a hack, but it sorta works, I guess
" nmap <Leader>jgs mawv/ <CR>"ty/ <CR>wvwh"ny/getters<CR>$a<CR><CR><Esc>xxapublic <Esc>"tpa<Esc>"npbiget<Esc>l~ea()<CR>{<CR><Tab>return <Esc>"npa;<CR>}<Esc>=<CR><Esc>/setters<CR>$a<CR><CR><Esc>xxapublic void <Esc>"npbiset<Esc>l~ea(<Esc>"tpa <Esc>"npa)<CR>{<CR><Tab>this.<Esc>"npa=<Esc>"npa;<CR>}<Esc>=<CR>`ak
"
"endfunction
" Some tricks for mutt
" F1 through F3 rewraps paragraphs
augroup MUTT
" au BufRead ~/.mutt/temp/mutt* set spell " <-- vim 7 required
au BufRead ~/.mutt/temp/mutt* nmap gqap
au BufRead ~/.mutt/temp/mutt* nmap gqqj
au BufRead ~/.mutt/temp/mutt* nmap kgqj
au BufRead ~/.mutt/temp/mutt* map! gqapi
au BufRead ~/.mutt/temp/mutt* map! gqqji
au BufRead ~/.mutt/temp/mutt* map! kgqji
augroup END
""""""""""""""""""""""""""""""""
"
" MISCELLANEOUS
"
""""""""""""""""""""""""""""""""
" (There is _ALWAYS_ a miscellaneous section)
" Enable CTRL-A/CTRL-X to work on octal and hex numbers, as well as characters
set nrformats=octal,hex,alpha
" Remember things between sessions
" '20 - remember marks for 20 previous files
" \"50 - save 50 lines for each register
" :20 - remember 20 items in command-line history
" % - remember the buffer list (if vim started without a file arg)
" n - set name of viminfo file
set viminfo='20,\"50,:20,%,n~/.viminfo
" Insert mode completion options
"set completeopt=menu,longest,preview
" Use menu to show command-line completion (in 'full' case)
" set wildmenu
" Set command-line completion mode:
" - on first <Tab>, when more than one match, list all matches and complete
" the longest common string
" - on second <Tab>, complete the next full match and show menu
set wildmode=list:longest,full
" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
set grepprg=grep\ -nH\ $*
" No place holders for
let g:Imap_UsePlaceHolders=0
" Look for the file in the current directory, then south until you reach home.
"set tags=tags;~/
" Shut up
set noerrorbells
" Always add the current file's directory to the path if not already there
"autocmd BufRead *
"let s:tempPath=escape(escape(expand("%:p:h"), ' '), '\ ')
" \ exec "set path-=".s:tempPath
" \ exec "set path^=".s:tempPath
"autocmd BufEnter * lcd %:p:h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment