185 lines
5.6 KiB
VimL
185 lines
5.6 KiB
VimL
"------------------------------------------------------------------------------
|
|
" File .vimrc
|
|
" jul.io
|
|
"------------------------------------------------------------------------------
|
|
"
|
|
"set nocompatible " use vim defaults
|
|
syntax on " use syntax highlighting
|
|
set background=dark " when using black background terminal
|
|
colorscheme ron " for bash in windows this fixes my colors in vim inside tmux
|
|
|
|
set number " line numbers
|
|
set relativenumber " relative line numbers! How cool is that?!
|
|
|
|
set clipboard=unnamed
|
|
set backspace=indent,eol,start " more powerful backspacing
|
|
set autoindent " always set autoindenting on
|
|
set formatoptions+=t
|
|
|
|
set nobackup " Don't keep a backup file
|
|
set viminfo='20,\"50 " read/write a .viminfo file, don't store more than
|
|
" 50 lines of registers
|
|
set history=200 " keep many lines of command line history
|
|
set showcmd " Show (partial) command in status line.
|
|
set showmatch " Show matching brackets.
|
|
set ignorecase " Do case insensitive matching
|
|
set smartcase " When searching with Uppercase Letters be Case-Sensitive, otherwise don't be
|
|
set incsearch " Incremental search
|
|
set hlsearch " Search highlight
|
|
hi Search ctermbg=LightGrey " change color for search hints
|
|
|
|
set noexpandtab
|
|
|
|
set tabstop=2
|
|
set sw=2
|
|
set so=7 "set 7 lines to the cursor when moving vertically with j/k
|
|
set foldcolumn=1 "add a bit of extra margin to the left
|
|
|
|
set smarttab
|
|
set smartindent
|
|
|
|
set enc=utf-8 " default UTF8 encoding
|
|
set fileencoding=utf-8 " default UTF8 encoding
|
|
set ruler " show the cursor position all the time
|
|
|
|
set directory=~/.vim/swap/
|
|
|
|
set lazyredraw "to speed up vim a bit
|
|
set regexpengine=1
|
|
|
|
" show current file with complete file in statusline
|
|
set laststatus=2
|
|
set statusline+=%F
|
|
|
|
filetype plugin on
|
|
filetype indent on
|
|
filetype on
|
|
|
|
" With a map leader it's possible to do extra key combinations
|
|
" like <leader>w saves the current file
|
|
" my mapleader is <spacebar> for easy access with both hands
|
|
let mapleader=" "
|
|
let g:mapleader=" "
|
|
|
|
" settings for vim 7
|
|
if version >= 700
|
|
set spellfile=~/.vimspell.de.add,~/.vimspell.en.add
|
|
" setlocal spell spelllang=de " enable spell checker
|
|
endif
|
|
|
|
hi LineTooLong cterm=bold ctermbg=red guibg=LightYellow
|
|
match LineTooLong /\%>80v.\+/
|
|
|
|
"useful mappings for managing tabs
|
|
map <leader>tn :tabnew<cr>
|
|
map <leader>to :tabonly<cr>
|
|
map <leader>tc :tabclose<cr>
|
|
map <leader>tm :tabmove
|
|
map <leader>t<leader> :tabnext
|
|
|
|
" Delete trailing white space on save, useful for some filetypes ;)
|
|
fun! CleanExtraSpaces()
|
|
let save_cursor = getpos(".")
|
|
let old_query = getreg('/')
|
|
silent! %s/\s\+$//e
|
|
call setpos('.', save_cursor)
|
|
call setreg('/', old_query)
|
|
endfun
|
|
|
|
" grep will sometimes skip displaying the file name
|
|
set grepprg=grep\ -nH\ $*
|
|
|
|
" 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_Folding=0 "I don't like folding.
|
|
set iskeyword+=:
|
|
|
|
" Press Space to turn off highlighting and clear any message already displayed.
|
|
nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
|
|
|
|
" Incrementing selected numbers (works, when numbers are in a column)
|
|
function! Incr()
|
|
let a = line('.') - line("'<")
|
|
let c = virtcol("'<")
|
|
if a > 0
|
|
execute 'normal! '.c.'|'.a."\<C-a>"
|
|
endif
|
|
normal `<
|
|
endfunction
|
|
vnoremap <C-a> :call Incr()<CR>
|
|
|
|
" Prss CTRL + _ (CTRL + SHIFT + -) to close a html tag
|
|
if filereadable(glob('~/.vim/scripts/closetag.vim')) | source ~/.vim/scripts/closetag.vim | endif
|
|
|
|
highlight ExtraWhitespace ctermbg=red guibg=red
|
|
match ExtraWhitespace /\s\+$\| \+\ze\t/
|
|
|
|
nnoremap <F2> :<C-U>%retab!<CR>:set list<CR>:%s/^\(\t\+\) */\1/<CR>
|
|
|
|
" Press F5 to insert datetime string from normal- and insert mode
|
|
nnoremap <F5> "=strftime("%c")<CR>P
|
|
inoremap <F5> <C-R>=strftime("%c")<CR>
|
|
|
|
" a few autocommands for when silly people send stupid file formats
|
|
" Read-only .doc through antiword
|
|
autocmd BufReadPre *.doc silent set ro
|
|
autocmd BufReadPost *.doc silent %!antiword "%"
|
|
|
|
" Read-only odt/odp through odt2txt
|
|
autocmd BufReadPre *.odt,*.odp silent set ro
|
|
autocmd BufReadPost *.odt,*.odp silent %!odt2txt "%"
|
|
|
|
" Read-only pdf through pdftotext
|
|
autocmd BufReadPre *.pdf silent set ro
|
|
autocmd BufReadPost *.pdf silent %!pdftotext -nopgbrk -layout -q -eol unix "%" -
|
|
"| fmt -w250
|
|
|
|
" Read-only rtf through unrtf
|
|
autocmd BufReadPre *.rtf silent set ro
|
|
autocmd BufReadPost *.rtf silent %!unrtf --text
|
|
|
|
" as long as vim isn't in diff-mode check the code at opening and closing
|
|
" also: special vimdiff-settings
|
|
if ! &diff
|
|
let g:syntastic_always_populate_loc_list = 1
|
|
let g:syntastic_auto_loc_list = 1
|
|
let g:syntastic_check_on_open = 1
|
|
let g:syntastic_check_on_wq = 1
|
|
|
|
nnoremap <leader>j <C-J>
|
|
nnoremap <leader>k <C-K>
|
|
nnoremap <leader>h <C-H>
|
|
nnoremap <leader>l <C-L>
|
|
endif
|
|
|
|
"tweaking my statusline
|
|
function! GitBranch()
|
|
return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
|
|
endfunction
|
|
|
|
function! StatuslineGit()
|
|
let l:branchname = GitBranch()
|
|
return strlen(l:branchname) > 0?' '.l:branchname.' ':''
|
|
endfunction
|
|
|
|
set laststatus=2 "always show statusline
|
|
|
|
set statusline=
|
|
set statusline+=%#PmenuSel#
|
|
set statusline+=%{StatuslineGit()}
|
|
set statusline+=%#LineNr#
|
|
set statusline+=\ %f
|
|
set statusline+=%m\
|
|
set statusline+=%=
|
|
set statusline+=%#CursorColumn#
|
|
set statusline+=\ %y
|
|
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
|
|
set statusline+=\[%{&fileformat}\]
|
|
set statusline+=\ %p%%
|
|
set statusline+=\ %l:%c
|
|
set statusline+=\
|
|
|