let mapleader = "," " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " Vundle bundles Bundle 'gmarik/Vundle.vim' Bundle 'tomasr/molokai' Bundle 'tpope/vim-dispatch' Bundle 'vim-scripts/JavaDecompiler.vim' Bundle 'jszakmeister/vim-togglecursor' Plugin 'xolox/vim-notes' Plugin 'xolox/vim-misc' Plugin 'kien/ctrlp.vim' Plugin 'alvan/vim-closetag' Plugin 'elzr/vim-json' Plugin 'fatih/vim-go' Plugin 'machakann/vim-sandwich' Plugin 'junegunn/vim-easy-align' Plugin 'darfink/vim-plist' Plugin 'skanehira/docker-compose.vim' Plugin 'dag/vim-fish' call vundle#end() let mapleader = ',' let g:mapleader = ',' silent! colorscheme molokai " mape space to execute makro q map @q " Nerdtree map :NERDTreeTabsToggle " ctr-p nnoremap :tabprevious nnoremap :tabnext set nu set nocompatible filetype indent plugin on set ignorecase set smartcase set backspace=indent,eol,start set autoindent set notimeout ttimeout ttimeoutlen=200 set background=dark syntax on set incsearch command Wm w|Make imap jk set cursorline " Return to last edit position when opening files (You want this!) autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif """""""""""""""""""""""""" GO Settings " go auto imports let g:go_fmt_autosave = 1 let g:go_fmt_fail_silently = 1 let g:go_fmt_command = "goimports" " Remap some commands au FileType go nmap r (go-run) au FileType go nmap b (go-build) au FileType go nmap ds (go-def-split) au FileType go nmap dv (go-def-vertical) au FileType go nmap dt (go-def-tab) " Highlighting let g:go_highlight_functions = 1 let g:go_highlight_methods = 1 let g:go_highlight_structs = 1 let g:go_highlight_interfaces = 1 let g:go_highlight_operators = 1 let g:go_highlight_build_constraints = 1 """""""""""""""""""""""" END GO Settings """""""""""""""""""""""" Omnicomplete Settings (more like IDE) set completeopt=longest,menuone,preview inoremap pumvisible() ? "\" : "\u\" inoremap pumvisible() ? '' : \ '=pumvisible() ? "\Down>" : ""' inoremap pumvisible() ? '' : \ '=pumvisible() ? "\Down>" : ""' "inoremap "inoremap inoremap """""""""""""""""""""""" END Omnicomplete Settings (more like IDE) let g:togglecursor_default = "block" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Maintainer: " Amir Salihefendic " http://amix.dk - amix@amix.dk " " Version: " 5.0 - 29/05/12 15:43:36 " " Blog_post: " http://amix.dk/blog/post/19691#The-ultimate-Vim-configuration-on-Github " " Awesome_version: " Get this config, nice color schemes and lots of plugins! " " Install the awesome version from: " " https://github.com/amix/vimrc " " Syntax_highlighted: " http://amix.dk/vim/vimrc.html " " Raw_version: " http://amix.dk/vim/vimrc.txt " " Sections: " -> General " -> VIM user interface " -> Colors and Fonts " -> Files and backups " -> Text, tab and indent related " -> Visual mode related " -> Moving around, tabs and buffers " -> Status line " -> Editing mappings " -> vimgrep searching and cope displaying " -> Spell checking " -> Misc " -> Helper functions " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => General """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Set to auto read when a file is changed from the outside set autoread " With a map leader it's possible to do extra key combinations " like w saves the current file let mapleader = "," let g:mapleader = "," """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => VIM user interface """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Set 7 lines to the cursor - when moving vertically using j/k set so=7 " Turn on the WiLd menu set wildmenu " Ignore compiled files set wildignore=*.o,*~,*.pyc " Height of the command bar set cmdheight=2 " A buffer becomes hidden when it is abandoned set hid " Configure backspace so it acts as it should act set backspace=eol,start,indent set whichwrap+=<,>,h,l " Don't redraw while executing macros (good performance config) set lazyredraw " Show matching brackets when text indicator is over them set showmatch " How many tenths of a second to blink when matching brackets set mat=2 " No annoying sound on errors set noerrorbells set novisualbell set t_vb= set tm=500 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Colors and Fonts """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Set extra options when running in GUI mode if has("gui_running") set guioptions-=T set guioptions+=e set t_Co=256 set guitablabel=%M\ %t endif " Set utf8 as standard encoding and en_US as the standard language set encoding=utf8 " Use Unix as the standard file type set ffs=unix,dos,mac """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Files, backups and undo """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Turn backup off, since most stuff is in SVN, git et.c anyway... set nobackup set nowb set noswapfile """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Text, tab and indent related """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Use spaces instead of tabs set expandtab " Be smart when using tabs ;) set smarttab " 1 tab == 4 spaces set shiftwidth=4 set tabstop=4 " Linebreak on 500 characters set lbr set tw=500 set ai "Auto indent set si "Smart indent set wrap "Wrap lines """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Moving around, tabs, windows and buffers """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Treat long lines as break lines (useful when moving around in them) map j gj map k gk """""""""""""""""""""""""""""" " => Status line """""""""""""""""""""""""""""" " Always show the status line set laststatus=2 " Format the status line set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Editing mappings """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Move a line of text using ALT+[jk] or Comamnd+[jk] on mac nmap mz:m+`z nmap mz:m-2`z vmap :m'>+`mzgv`yo`z vmap :m'<-2`>my` nmap vmap vmap endif " Delete trailing white space on save, useful for Python and CoffeeScript ;) func! DeleteTrailingWS() exe "normal mz" %s/\s\+$//ge exe "normal `z" endfunc autocmd BufWrite *.py :call DeleteTrailingWS() autocmd BufWrite *.coffee :call DeleteTrailingWS() """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Misc """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Remove the Windows ^M - when the encodings gets messed up noremap m mmHmt:%s///ge'tzt'm """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Helper functions """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" function! CmdLine(str) exe "menu Foo.Bar :" . a:str emenu Foo.Bar unmenu Foo endfunction function! VisualSelection(direction) range let l:saved_reg = @" execute "normal! vgvy" let l:pattern = escape(@", '\\/.*$^~[]') let l:pattern = substitute(l:pattern, "\n$", "", "") if a:direction == 'b' execute "normal ?" . l:pattern . "^M" elseif a:direction == 'gv' call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.') elseif a:direction == 'replace' call CmdLine("%s" . '/'. l:pattern . '/') elseif a:direction == 'f' execute "normal /" . l:pattern . "^M" endif let @/ = l:pattern let @" = l:saved_reg endfunction " Returns true if paste mode is enabled function! HasPaste() if &paste return 'PASTE MODE ' en return '' endfunction " Don't close window, when deleting a buffer command! Bclose call BufcloseCloseIt() function! BufcloseCloseIt() let l:currentBufNum = bufnr("%") let l:alternateBufNum = bufnr("#") if buflisted(l:alternateBufNum) buffer # else bnext endif if bufnr("%") == l:currentBufNum new endif if buflisted(l:currentBufNum) execute("bdelete! ".l:currentBufNum) endif endfunction " make as :m command MyMake :w|:Make " Use :ww instead of :WriteWithSudo cnoreabbrev m MyMake " tex files with textwidth 80 au BufRead,BufNewFile *.tex setlocal textwidth=80 set fo-=t set fo+=c command JsonIndentReorder :%!python -m json.tool command JsonIndent :%!python3 -c "import json, sys, collections; print(json.dumps(json.loads(sys.stdin.read(), object_pairs_hook=collections.OrderedDict), indent=4))" command XmlIndent :%!xmllint --format - " set font and size in MacVim set guifont=Hack-Regular:h15 " disable terminal bell in MacVim autocmd! GUIEnter * set vb t_vb= " set shortcut for easyalign au FileType markdown vmap a :EasyAlign* " unlimited undos even between closing and opening the editor set undofile set undodir=~/.vim/undodir