Skip to content

Instantly share code, notes, and snippets.

@mikaelj
Created September 19, 2013 09:45
Show Gist options
  • Save mikaelj/6621281 to your computer and use it in GitHub Desktop.
Save mikaelj/6621281 to your computer and use it in GitHub Desktop.
vimrc
set nocompatible
set backspace=indent,eol,start
set ruler
set showcmd
set wildmenu
set fo=cqrt
set laststatus=2
"set textwidth=78
set textwidth=0
set ww=<,>,h,l
set autoindent
" set no error bells
set noeb visualbell
set expandtab
set tabstop=4
set shiftwidth=4
set expandtab
let mapleader = ","
let maplocalleader = ","
syn on
filetype plugin indent on
" always display minimum 5 lines above and below the cursor
set scrolloff=5
" do *not* resize all windows.
set noequalalways
"set winfixheight " can be set if equalalways is on to avoid height/width maximization
" folding
set foldmethod=indent
set foldlevel=0
set foldnestmax=2
"------------------------
" statusline
"------------------------
set fillchars=stl:\ ,stlnc:\ ,vert:\|,fold:\ ,diff:\
set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P\ of\ %L\ \(%.45{getcwd()}\)
" ---------------------------------------------
" Completion w/ Shift-TAB (xfce4-terminal)
" Note: SuperTab might remap stuff..
" ---------------------------------------------
if !has("gui_running")
imap <Esc>[Z <C-P>
vmap <Esc>[Z <
nmap <Esc>[Z <<
nmap <Tab> >>
endif
" Esc gets you back to original, Enter selects.
inoremap <expr> <Esc> pumvisible()?"\<C-E>":"\<Esc>"
inoremap <expr> <CR> pumvisible()?"\<C-Y>":"\<CR>"
"inoremap <expr> <CR> pumvisible()?"\<C-Y>":"\<CR>"
"inoremap <expr> <CR> pumvisible()?"\<C-Y>":""
inoremap <expr> j pumvisible()?"\<C-N>":"j"
inoremap <expr> k pumvisible()?"\<C-P>":"k"
" word_complete.vim plugin. Select Mode good for lambda list completion?
" default key Tab
" let g:WC_accept_key = "<CR>"
"
"--------------------------
" Tags magic
"--------------------------
" ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
" Look for the tags file in the current directory,
" and look for the tags file in the _current file's_ directory. With the ;
" appended to the end, vim searches (see |file-searching| until / is reached)
set tags=tags,./tags;
" jump to tag: ctrl-space (which yields a ctrl-@)
map <C-@> <C-]>
let OmniCpp_ShowPrototypeInAbbr = 1
" alternate script
nmap <Leader>in :A<CR>
nmap <Leader>is :AS<CR>
nmap <Leader>ivs :AV<CR>
" jump to the insert point after pasting
nmap <Leader>p p`.
nmap <Leader>P P`.
" always open new vertical splits to the right
set splitright
" make mouse work for Terminal-vims
set mouse=nv
"---------------------------------------------
" Disable cursorline on inactive buffers
"---------------------------------------------
"autocmd WinLeave * set nocursorline
"autocmd WinEnter * set cursorline
set cursorline
" 256 colors, yay!
set t_Co=256
set number
set whichwrap=h,l,[,]
set showmatch
" move within long lines
noremap j gj
noremap k gk
nnoremap <C-J> <C-W>j
nnoremap <C-K> <C-W>k
"---------------------------
" Misc
"---------------------------
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif
" keep 50 lines of command line/search/etc history
set history=50
" ignore case, except if there's at least one upper-case character
" highlight search results
set ignorecase
set smartcase
set hlsearch
"set pastetoggle=<F2>
" Shift F2: gnome-ish copy buffer (copy text)
nmap O1;2Q :set paste<CR>"+p:set nopaste<CR>
" F2: X copy buffer
nmap <F2> :set paste<CR>"*p:set nopaste<CR>
"imap <F2> <C-O>:set paste|normal "*p|set nopaste<CR>
" loose the BRGNCC
set novisualbell
set noerrorbells
"Show menu with possible completions
set wildmenu
" Ignore these files when completing names and in Explorer
set wildignore=.svn,CVS,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif
" [nvilc]noremap means no remapping of right hand side.
" where nvilc is normal, visual, insert, ...
"--------------------------
" Tabs
"--------------------------
" also, gt/gT...
" xfce4-terminal, ubuntu:
" C-PageUp = <Esc>[5;5~
" C-PageDown = <Esc>[6;5~
" C-PageUp, C-PageDown
nmap <Esc>[5;5~ :tabprevious<cr>
nmap <Esc>[6;5~ :tabnext<cr>
" C-Right
" imap <C-PageUp> <ESC>:tabprevious<cr>i
" imap <C-PageDown> <ESC>:tabnext<cr>i
nmap <C-n> :tabnew<cr>
" note: requires XON/XOFF disabled! (`stty -ixon`)
:nmap <C-q> :tabclose<cr>
"--------------------------------
" Buffers
"--------------------------------
" xfce4-terminal, ubuntu:
" M-PageDown = <Esc>[6;3~
" M-PageUp = <Esc>[5;3~
" switch buffers
nmap <Esc>[6;3~ :bnext<CR>
nmap <Esc>[5;3~ :bprevious<CR>
" C-right, C-left
nmap <Esc>[1;5C :bnext<CR>
nmap <Esc>[1;5D :bprevious<CR>
" switch to previous buffer
noremap <F10> :b#<CR>
" switch panes
nnoremap <F8> :cnext<CR>
nnoremap <F7> :cprev<CR>
" scroll down half a page w/ m-space, up with -
nmap <Esc><Space> <C-D>
vmap <Esc><Space> <C-D>
nnoremap - <C-U>
" remap Ex-mode into reformatting the current paragraph in visual mode
" or the current paragraph in normal mode (plus following if count specified).
nnoremap Q gqap
vnoremap Q gq
" Move around in the windows and make them maximum size
" nnoremap <Left> <C-W>h<C-W>_:vertical resize 100000<CR>
" nnoremap <Right> <C-W>l<C-W>_:vertical resize 100000<CR>
" nnoremap <Down> <C-W>j<C-W>_
" nnoremap <Up> <C-W>k<C-W>_
" Move around in the windows
" nnoremap <Left> <C-W>h
" nnoremap <Right> <C-W>l
" nnoremap <Down> <C-W>j
" nnoremap <Up> <C-W>k
" temporary UTF-8 encoding
" set termencoding=latin1
set termencoding=utf-8
set encoding=utf-8
"let &termencoding = &encoding
"this seems to work, utf-8 doesn't seem to..
set fileencoding=utf-8
setglobal fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,default,latin1
setglobal fileencodings=ucs-bom,utf-8,default,latin1
" Spelling!
if has("spell")
" turn spelling on by default
set nospell
" toggle spelling with F4 key
map <F4> :set spell!<CR><Bar>:echo "Spell Check: " . strpart("OffOn", 3 * &spell, 3)<CR>
" they were using white on white
highlight PmenuSel ctermfg=black ctermbg=lightgray
" limit it to just the top 10 items
set sps=best,10
endif
" only the status window left
set winminheight=0
" smart indentation everywhere
set smartindent
" disable all current autocammands in case vimrc gets sourced twice
" au!
"
" smart-indent for python files, yay!
augroup filetypedetect
autocmd! BufNewFile,BufRead *.py set syntax=python cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd! BufNewFile,BufRead *.tac set cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd! BufNewFile *.py 0r ~/.vim/skeleton/python.py
" lilypond
autocmd! BufNewFile,BufRead *.ly setf lilypond
set runtimepath+=/usr/share/lilypond/2.10.5/vim/
augroup END
set runtimepath+=~/.vim/slimv
set runtimepath^=~/.vim/bundle/ctrlp.vim
set runtimepath+=~/.local/lib/python2.7/site-packages/powerline/bindings/vim
" auto-close XML tags on <C-_>
let g:closetag_html_style=1
autocmd Filetype xhtml,html,xml,xsl,php,kid source ~/.vim/plugin/closetag.vim | set tw=0
autocmd BufNewFile,BufRead *.txt set tw=120
let python_highlight_all=1
let python_slow_sync=1
runtime plugin/matchit.vim
" -------------------------------------------
" Lisp
" -------------------------------------------
"
"nmap <F12> :set filetype=lisp<CR><F12>
"au Filetype lisp nmap <buffer> ä <Plug>SexpPrevious
"au Filetype lisp nmap <buffer> Ö <Plug>SexpNext
au Filetype lisp imap <buffer> ä (
au Filetype lisp imap <buffer> ö )
" show tabs as >-xN in Makefiles and Python source
autocmd FileType make,py set list listchars=tab:>-
au BufRead,BufNewFile *.bream setfiletype java
" ----- org mode
au! BufRead,BufWrite,BufWritePost,BufNewFile *.org
au BufEnter *.org call org#SetOrgFileType()
" function! ActivateCWindow()
" python << EOF
" import vim
"
" if vim.current.buffer.name == "[Error List]":
" vim.command("b#")
" else:
" for win in vim.windows():
" if win.buffer.name == "[Error List]":
"
"
"
" EOF
" endfunction
"if filereadable(".session")
" source .session
"endif
" colorscheme marklar
" colorscheme desert_black
" colorscheme desert
" colorscheme murphy
" colorscheme evening2
" colorscheme desert256
set background=dark
colorscheme jellybeans
"hi StatusLine ctermbg=160 ctermfg=15
" yellow on red
hi StatusLine ctermbg=1 ctermfg=11
" black on white
hi StatusLineNC ctermbg=8 ctermfg=0
hi DiffDelete ctermbg=red ctermfg=white
hi DiffAdd ctermbg=green ctermfg=black
hi DiffChange ctermbg=yellow ctermfg=black
" hi DiffText
if has("gui_running")
hi Normal guibg=Black
endif
"hi StatusLine ctermbg=white ctermfg=160
"hi StatusLineNC ctermbg=black ctermfg=gray
"hi Folded term=NONE ctermbg=0 ctermfg=241 guifg=Green guibg=Black
"hi WildMenu term=NONE cterm=bold ctermbg=blue ctermfg=8
"
" clear blue background, white foreground
"hi CursorLine cterm=NONE guibg=#333333 guifg=#ffffff ctermbg=235 ctermfg=255
hi NonText term=NONE guibg=black guifg=white ctermbg=black ctermfg=white
"hi TabLineFill ctermfg=black ctermbg=black guifg=black guibg=black
"hi TabLine term=NONE ctermfg=gray ctermbg=black guifg=gray guibg=black
"hi TabLineSel term=NONE ctermfg=white ctermbg=black guifg=white guibg=black
hi TabLineFill ctermfg=233 ctermbg=black guifg=black guibg=black
hi TabLine term=NONE cterm=bold ctermfg=white ctermbg=black guifg=gray guibg=black
hi TabLineSel term=NONE ctermfg=white ctermbg=160 guifg=white guibg=red
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment