2
0
mirror of https://github.com/webgefrickel/dotfiles synced 2024-11-09 13:10:27 +00:00
steffen-dotfiles/vimrc

452 lines
11 KiB
VimL
Raw Normal View History

" nocompatible mode for a real vim
set nocompatible
" switch filetype of before starting vundle
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" load the vundle bundle of course
Bundle 'gmarik/vundle'
" plugins
Bundle 'Raimondi/delimitMate'
Bundle 'SirVer/ultisnips'
Bundle 'bling/vim-airline'
Bundle 'chrisbra/NrrwRgn'
Bundle 'editorconfig/editorconfig-vim'
Bundle 'edsono/vim-matchit'
2013-06-06 09:32:02 +00:00
Bundle 'ervandew/supertab'
Bundle 'godlygeek/tabular'
2013-12-11 13:00:05 +00:00
Bundle 'justinmk/vim-sneak'
Bundle 'kien/ctrlp.vim'
2014-01-16 17:21:18 +00:00
Bundle 'kshenoy/vim-signature'
2014-02-22 23:47:08 +00:00
Bundle "mattn/emmet-vim"
Bundle 'mattn/gist-vim'
Bundle 'mattn/webapi-vim'
2013-12-11 13:00:05 +00:00
Bundle 'mbbill/undotree'
Bundle 'mhinz/vim-signify'
Bundle 'rizzatti/dash.vim'
2013-12-07 14:33:30 +00:00
Bundle 'rizzatti/funcoo.vim'
Bundle 'rking/ag.vim'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/syntastic'
Bundle 'terryma/vim-expand-region'
Bundle 'terryma/vim-multiple-cursors'
Bundle 'tomtom/tcomment_vim'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-ragtag'
Bundle 'tpope/vim-repeat'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-unimpaired'
" Additional syntaxes
2013-12-11 13:00:05 +00:00
Bundle 'beyondwords/vim-twig'
Bundle 'elzr/vim-json'
Bundle 'hail2u/vim-css3-syntax'
2014-02-22 23:47:08 +00:00
Bundle 'joshtronic/php.vim'
Bundle 'mustache/vim-mustache-handlebars'
Bundle 'othree/html5.vim'
Bundle 'pangloss/vim-javascript'
Bundle 'tpope/vim-git'
Bundle 'tpope/vim-haml'
2013-12-07 14:33:30 +00:00
Bundle 'tpope/vim-markdown'
Bundle 'webgefrickel/vim-typoscript'
2014-01-16 17:21:18 +00:00
" Color themes -- one to rule them all!
2013-05-14 17:32:05 +00:00
Bundle 'altercation/vim-colors-solarized'
" and reset auto-filetype after loading all bundles
filetype plugin indent on
syntax on
set ruler " show where you are in the document
set cursorline " highligh current line
set ttyfast " faster terminal usage
set showcmd " show me what im doing. helps alot
2014-02-22 23:47:08 +00:00
set noshowmode " dont show active mode -- we use airline for that
set hidden " allows for switching buffers without writing
set relativenumber " relative line numbers are mothereffin awesome -- see how far your commands will go
set nowrap " dont wrap lines around
set sidescroll=10 " smoother side-scrolling
set sidescrolloff=5
set scrolljump=5 " Lines to scroll when cursor leaves screen
set scrolloff=3 " Minimum lines to keep above and below cursor
2013-12-07 14:33:30 +00:00
set lazyredraw " Don't redraw while executing macros
" nice Whitespace chars
set list!
2013-12-07 14:33:30 +00:00
set listchars=extends,precedes,tab:▸\ ,trail
" Tabs and Whitespace
set tabstop=2
set softtabstop=2
set shiftwidth=2
set shiftround
set smarttab
set expandtab
set autoindent
" use the mouse for scrolling, yeah
set mouse=a
" use ag for grepping
set grepprg=ag
" no delay for escaping
set noesckeys
2013-12-07 14:33:30 +00:00
" gui options for macvim
if has('gui_running')
set guifont=Menlo\ for\ Powerline:h12 " a nice font here
set linespace=1 " menlo is nice, but very dense...
set guioptions-=T " no toolbar
set guioptions-=L " no left scrollbar
set guioptions-=r " no right scrollbar
endif
" mac terminal-vim play nicely with tmux
if &term =~ '^screen'
" tmux will send xterm-style keys when its xterm-keys option is on
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
" map <Esc>[B <Down>
endif
2013-05-14 17:32:05 +00:00
2013-07-19 18:40:08 +00:00
set t_Co=256
set background=dark
2014-01-16 17:21:18 +00:00
colorscheme solarized
2013-07-19 18:40:08 +00:00
let g:solarized_termtrans = 1
let g:solarized_contrast = 'high'
2014-02-22 23:47:08 +00:00
" minor optical fix vor syntastic / vim-signature
2014-01-16 17:21:18 +00:00
highlight SignColumn ctermbg=8
2012-11-29 14:56:52 +00:00
set fillchars=""
" Automatically read a file that has changed on disk
set autoread
set encoding=utf-8 " Yeah. UTF-8 FTW!
set fileformat=unix
set virtualedit=all " every mode active from v V to StrgV
" always put a status line in and make the command line 2 lines high
set laststatus=2
set ch=2
" Add a $ to the end of a selection vor easier overwriting vizualisation
2013-12-04 10:51:06 +00:00
set cpo+=$
" 2 spaces after a sentence for easier text manupulation
set cpo+=J
" Searching
set ignorecase
set smartcase
set gdefault
set incsearch
set showmatch
set hlsearch
set wrapscan " set the search scan to wrap lines
set backspace=indent,eol,start " Allow backspacing over everything in insert mode
" Tab completion, and ignore some filetypes
set wildmode=list:longest,list:full
2013-12-07 14:33:30 +00:00
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*.,*/.DS_Store
set wildmenu
set nobackup " no backups
set nowritebackup
set noswapfile " no swp-files
" Better folding
set foldmethod=indent
2013-07-05 16:49:04 +00:00
setlocal foldignore=
set foldnestmax=20 " max 20 levels of folding
set nofoldenable " dont fold by default - let me do it
set foldlevelstart=1 " deactivate folding on fileload
set noerrorbells " don't beep
set visualbell " don't beep
2013-12-07 14:33:30 +00:00
" pasting and copying
set pastetoggle=<F2> " toggle paste-mode for c&p with F2
set clipboard=unnamed " osx + tmux fix
" get rid of the delay when pressing O (for example)
2013-12-11 13:00:05 +00:00
set timeout timeoutlen=800 ttimeoutlen=100
2013-12-07 14:33:30 +00:00
2013-11-23 19:00:03 +00:00
" Custom key mappings and shortcuts
" ======================================================================
2013-07-05 16:49:04 +00:00
" set the leader to comma , and ; == : -- faster commands
let mapleader = ","
2014-02-22 23:47:08 +00:00
let g:mapleader = ","
let maplocalleader = ","
let g:maplocalleader = ","
nnoremap ; :
2013-12-31 13:54:47 +00:00
vnoremap ; :
2013-12-07 14:33:30 +00:00
" Swap v and CTRL-V, because Block mode is more useful
nnoremap v <C-V>
nnoremap <C-V> v
vnoremap v <C-V>
vnoremap <C-V> v
" jk nice behaviour (screen lines vs. shown lines)
nnoremap j gj
nnoremap k gk
" behave - yank just like D and C
nnoremap Y y$
nnoremap / /\v
vnoremap / /\v
2012-11-27 22:41:10 +00:00
inoremap jj <Esc>
" Switch between windows
nnoremap <tab> <C-w><C-w>
nnoremap <S-tab> <C-w>W
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
nnoremap N Nzz
nnoremap n nzz
" Adjust viewports to the same size
nnoremap <leader>= <C-w>=
" reset search
nnoremap <leader><space> :noh<cr>
" open new vertical split and change to split
nnoremap <leader>\ <C-w>v<C-w>l
nnoremap <leader>- <C-w>s<C-w>j
" open a new split and edit the vimrc // easy sourcing vimrc
2013-12-11 13:00:05 +00:00
nnoremap <leader>ve <C-w>v<C-w>l :e ~/.vimrc<cr>
2013-07-19 17:17:05 +00:00
nnoremap <leader>vs :source ~/.vimrc<cr>
2013-05-14 17:32:05 +00:00
" Opens an edit command with the path of the currently edited file filled in
nnoremap <leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
2013-12-07 14:33:30 +00:00
" start a new document-wide seach-replace
2013-07-05 16:49:04 +00:00
nnoremap <leader>f :%s/
" dont use the arrow keys in insert mode
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
" but use them for usefull stuff in normal mode-- switching buffers
nnoremap <up> :bfirst<cr>
nnoremap <down> :blast<cr>
nnoremap <left> :bp<cr>
nnoremap <right> :bn<cr>
" Bubble/indent lines using unimpaired
nmap <C-k> [e
nmap <C-j> ]e
nmap <C-h> <<
nmap <C-l> >>
2014-01-14 13:43:23 +00:00
vmap <C-k> [egv
vmap <C-j> ]egv
vmap <C-h> <gv
vmap <C-l> >gv
" Yank text to the OS X clipboard
noremap <leader>y "*y
noremap <leader>Y "*Y
" paste keeping indentation
nnoremap <leader>p p`[v`]=
" no HELP while mishitting ESC - awesome
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" deactivate stupid ex-mode and man-page stuff
nnoremap Q <nop>
nnoremap K <nop>
" upper/lower word
2013-06-06 09:32:02 +00:00
nmap <leader>u mQviwU`Q
nmap <leader>l mQviwu`Q
" Swap two words
2013-07-19 17:17:05 +00:00
nmap <leader>sw :s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<CR>`'
" change working directory to current file
2013-07-19 17:17:05 +00:00
nnoremap <leader>w :cd %:p:h<CR>:pwd<CR>
2012-12-03 12:46:43 +00:00
" reload files when set autoread is active with F5
2013-12-07 14:33:30 +00:00
lnoremap <F5> :checktime<CR>
2012-12-03 12:46:43 +00:00
2013-07-05 16:49:04 +00:00
" when over a class in html hit fc to find that class in css/scss/js
nnoremap <leader>c :execute "vimgrep /" . expand("<cword>") . "/j **" <Bar> cnext<CR>
2013-12-31 13:54:47 +00:00
" short command to strip trainling whitepsace
nnoremap <leader>s ms:%s/\s\+$//e<cr>:noh<cr>`s
2012-12-03 12:46:43 +00:00
" Find merge conflict markers
map <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
" For when you forget to sudo.. Really Write the file.
cmap w!! w !sudo tee % >/dev/null
2014-02-22 16:36:04 +00:00
" Map <Leader>j to display all lines with keyword under cursor and ask which one to jump to
nmap <Leader>j [I:let nr = input("Enter line number: ")<Bar>exe "normal " . nr ."[\t"<CR>
2013-11-23 19:00:03 +00:00
" Plugins
" ======================================================================
"
" Ag
nnoremap <leader>a :Ag!<space>
nnoremap <leader>A :Ag! <C-r><C-w><cr>
2013-11-23 19:00:03 +00:00
" NERDtree
nnoremap <leader>n :NERDTreeToggle<cr>
2013-12-07 14:33:30 +00:00
nnoremap <leader>o :NERDTreeFind<cr>
let NERDTreeAutoDeleteBuffer=1
2012-05-29 16:29:51 +00:00
let NERDTreeMinimalUI=1
let NERDTreeWinSize=50
2012-05-29 16:29:51 +00:00
let NERDTreeShowHidden=1
2013-11-23 19:00:03 +00:00
" fugitive shortcuts (20+ increases window-height)
2013-05-14 17:32:05 +00:00
nnoremap <silent> <leader>gs :Gstatus<CR><C-w>20+
nnoremap <silent> <leader>gd :Gdiff<CR><C-w>20+
nnoremap <silent> <leader>gc :Gcommit<CR><C-w>20+
nnoremap <silent> <leader>gb :Gblame<CR><C-w>20+
nnoremap <silent> <leader>gl :Glog<CR><C-w>20+
nnoremap <silent> <leader>gp :Git push<CR><C-w>20+
nnoremap <silent> <leader>gw :Gwrite<CR><C-w>20+
2013-11-23 19:00:03 +00:00
2013-12-11 13:00:05 +00:00
" Undotree
nnoremap <F3> :UndotreeToggle<cr>
" TComment
nnoremap <leader>/ :TComment<CR>
vnoremap <leader>/ :TComment<CR>
2013-07-05 16:49:04 +00:00
inoremap <leader>/ <Esc>:TComment<CR>
2013-11-23 19:00:03 +00:00
2013-12-07 14:33:30 +00:00
" Tabularize
nmap <Leader>s= :Tabularize /=<CR>
vmap <Leader>s= :Tabularize /=<CR>
nmap <Leader>s{ :Tabularize /{<CR>
vmap <Leader>s{ :Tabularize /{<CR>
nmap <Leader>s: :Tabularize /:<CR>
vmap <Leader>s: :Tabularize /:<CR>
nmap <Leader>s, :Tabularize /,<CR>
vmap <Leader>s, :Tabularize /,<CR>
nmap <Leader>s<Bar> :Tabularize /<Bar><CR>
vmap <Leader>s<Bar> :Tabularize /<Bar><CR>
2013-05-14 17:32:05 +00:00
2013-12-11 13:00:05 +00:00
" vim sneak
let g:sneak#use_ic_scs = 1
let g:sneak#map_netrw = 0
let g:sneak#streak = 1
nmap <Bslash> <Plug>SneakNext
nmap \| <Plug>SneakPrevious
xmap <Bslash> <Plug>VSneakNext
xmap \| <Plug>VSneakPrevious
2013-11-23 19:00:03 +00:00
" ultisnips
let g:UltiSnipsSnippetDirectories = ["snippets"]
2013-05-13 19:51:07 +00:00
2013-11-23 19:00:03 +00:00
" Syntastic
" no checking for xhtml/html -- because of fluidtemplate for TYPO3
" and no checking for scss.css because of CSS3 and SASS-Variable
2013-11-23 19:00:03 +00:00
let g:syntastic_auto_jump = 0
2013-12-04 10:51:06 +00:00
let g:syntastic_mode_map = {
2013-11-23 19:00:03 +00:00
\ 'mode': 'active',
\ 'active_filetypes': ['ruby', 'php', 'javascript'],
2013-12-04 10:51:06 +00:00
\ 'passive_filetypes': ['xhtml', 'html', 'scss', 'scss.css', 'css']
\ }
2013-11-23 19:00:03 +00:00
" CtrlP (using Ag)
2013-07-05 16:49:04 +00:00
nnoremap <leader>b :CtrlPBuffer<cr>
nnoremap <leader>r :CtrlPMRU<cr>
2013-12-07 14:33:30 +00:00
let g:ctrlp_map = '<leader>t'
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
let g:ctrlp_use_caching = 0
let g:ctrlp_switch_buffer = 0 " easier split screens
2013-07-05 16:49:04 +00:00
let g:ctrlp_working_path_mode = 0 " dont try to change my working directory
let g:ctrlp_max_height = 12
2013-11-23 19:00:03 +00:00
" Gist filetype-detection
let g:gist_detect_filetype = 1
2013-12-07 14:33:30 +00:00
let g:gist_open_browser_after_post = 1
" airline config
2013-11-23 19:00:03 +00:00
let g:airline_theme = 'solarized'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '◀'
2013-07-19 17:17:05 +00:00
" Mac Dash.app integration
nmap <silent> <leader>d <Plug>DashSearch
nmap <silent> <leader>D <Plug>DashGlobalSearch
let g:dash_map = {
\ 'javascript' : 'jquery'
\ }
2014-02-22 23:47:08 +00:00
" emmet -- only use the html-expansion
let g:user_emmet_install_global = 0
autocmd FileType html,php,twig EmmetInstall
imap <expr> <C-e> emmet#expandAbbrIntelligent("\<C-e>")
2014-01-16 17:21:18 +00:00
2013-11-23 19:00:03 +00:00
" Other functions / Onload, Autocommands
" ======================================================================
" spell correction on text-files
autocmd BufRead,BufNewFile *.{md|rst|txt} setlocal spell
2013-12-07 14:33:30 +00:00
" add the dash to keywords -- makes better css/js/html search
2013-12-11 13:00:05 +00:00
" do this for specific files only (not in php/rb e.g.)
2013-12-07 14:33:30 +00:00
au BufNewFile,BufRead *.{json,js,css,scss,html} set iskeyword+=-
au BufNewFile,BufRead *.{json,js,css,scss,html} set iskeyword-=_
" Syntaxes for other files
2013-11-23 19:00:03 +00:00
au BufNewFile,BufRead Phakefile set ft=php
2013-12-31 13:54:47 +00:00
au BufNewFile,BufRead *.twig set ft=html.twig
2014-02-22 23:47:08 +00:00
au BufNewFile,BufRead *.twig set ft=html.twig
2014-02-22 16:36:04 +00:00
au BufNewFile,BufRead *.{txt,ts} set ft=typoscript
2013-11-23 19:00:03 +00:00
" Remember last location/cursor in file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif