Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set nocompatible " be iMproved, required
- filetype off " required
- " set the runtime path to include Vundle and initialize
- set rtp+=~/.vim/bundle/Vundle.vim
- call vundle#begin()
- Plugin 'VundleVim/Vundle.vim'
- " General Plugins
- Plugin 'tpope/vim-fugitive'
- Plugin 'scrooloose/syntastic'
- Plugin 'scrooloose/nerdtree'
- Plugin 'tomtom/tcomment_vim'
- Plugin 'Valloric/YouCompleteMe' " Requires Additional Installation
- Plugin 'ctrlpvim/ctrlp.vim'
- Plugin 'vim-scripts/YankRing.vim'
- Plugin 'rking/ag.vim' " Requires Additional Installation
- Plugin 'jeetsukumaran/vim-buffergator' " Requires Additional Installation
- " Javascript plugins
- Plugin 'pangloss/vim-javascript', { 'for': ['javascript', 'javascript.jsx'] }
- " Plugin 'mxw/vim-jsx', { 'for': ['javascript', 'javascript.jsx'] }
- " All of your Plugins must be added before the following line
- call vundle#end() " required
- filetype plugin indent on " required
- " To ignore plugin indent changes, instead use:
- "filetype plugin on
- "----------------------------
- """" Basic Settings""""
- "----------------------------
- "----leader settings----
- let mapleader=","
- "----basic settings----
- syntax enable
- set ffs=unix,dos,mac " Use Unix as the standard file type
- set encoding=utf8 " Set utf8 as standard encoding and en_US as the standard language
- " Configure backspace so it acts as it should act
- set backspace=2
- set backspace=indent,eol,start
- fixdel
- " Turn backup off, since most stuff is in SVN, git et.c anyway...
- set nobackup
- set nowb
- set noswapfile
- "share the main mac clipboard
- set clipboard=unnamed
- "----search settings----
- set ignorecase
- set smartcase
- :set hlsearch "highlight all search results after a search
- " clear last seach with leader space
- nnoremap <leader><space> :noh<cr>
- "----indent settings----
- set cindent
- set tabstop=2
- set shiftwidth=2
- set expandtab
- :noremap > >>
- :noremap < <<
- "----status line----
- set laststatus=2 " Always show the status line
- highlight User1 gui=NONE guifg=#ff0000 guibg=#d0d0e0
- " Format the status line
- set statusline=\ %{HasPaste()}%F%1*%m%*%r%h\ %w\ ln%l:%c
- set statusline+=%#warningmsg#
- set statusline+=%{SyntasticStatuslineFlag()}
- set statusline+=%*
- 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 = 0
- "----other tweaks----
- " quick editing the vimrc (and sourcing it, and if you want, auto sourcing after saving)
- nnoremap <silent> <leader>ev :tabedit $MYVIMRC<CR>
- nnoremap <silent> <leader>sv :so $MYVIMRC<CR>
- " for when you accidentally capitalize W when typing :w to save
- :command! W w
- :command! Q w
- :command! Wq wq
- :command! WQ wq
- " Toggle paste mode on and off
- map <leader>pp :setlocal paste!<cr>
- " Remember cursor position between vim sessions
- autocmd BufReadPost *
- \ if line("'\"") > 0 && line ("'\"") <= line("$") |
- \ exe "normal! g'\"" |
- \ endif
- map 0 ^ " Remap VIM 0 to first non-blank character
- autocmd BufRead * normal zz " center buffer around cursor when opening files
- autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " turn of auto-comments on new-line
- " Remove Error Bells
- set noerrorbells visualbell t_vb=
- if has('autocmd')
- autocmd GUIEnter * set visualbell t_vb=
- endif
- " Ctrl-A to select all
- noremap <c-a> ggVGy
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Filetype Specific
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- "----javascript settings----
- let g:vimjs#casesensistive = 1
- let g:vimjs#smartcomplete = 1
- set completeopt-=preview
- " run vim-jsx in js files
- let g:jsx_ext_required = 0
- " autocmd FileType typescript setlocal completeopt+=
- let g:typescript_indent_disable = 1
- let g:tsuquyomi_disable_quickfix = 1
- let g:vim_json_syntax_conceal = 0
- " angular stuff
- let g:used_javascript_libs = 'angularjs,angularuirouter'
- "----python settings----
- " Delete Trailing Spaces for Python
- autocmd BufWrite *.py :call DeleteTrailingWS()
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Appearance Specific
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- colorscheme molokai
- hi Normal ctermbg=NONE
- :set nowrap
- :set textwidth=0
- :set wrapmargin=0
- set relativenumber "Relative Line Numbering"
- set showmatch " Show matching brackets when text indicator is over them
- """"""""""""""""""""""""""""""
- " => Visual mode related
- """"""""""""""""""""""""""""""
- " Visual mode pressing * or # searches for the current selection
- " Super useful! From an idea by Michael Naumann
- vnoremap <silent> * :call VisualSelection('f', '')<CR>
- vnoremap <silent> # :call VisualSelection('b', '')<CR>
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " => Moving around, tabs, windows and buffers
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " move by 10's with capital hjkl
- noremap J 10j
- noremap K 10k
- noremap H 10h
- noremap L 10l
- "----splits----
- " Easier way to move between splits
- nnoremap <C-j> <C-W>j
- nnoremap <C-k> <C-W>k
- nnoremap <C-h> <C-W>h
- nnoremap <C-l> <C-W>l
- " Increase and Decrease Split Size
- nnoremap + <c-w>>
- nnoremap - <c-w><
- nnoremap <bar> <c-w>=
- """ ubuntu alt mappings without meta
- " Close the current buffer with alt q
- nnoremap q :bd<cr>
- " Close all the buffers with alt d
- nnoremap d :bufdo bd<cr>
- nnoremap l :bnext!<cr>
- nnoremap h :bprevious!<cr>
- """ mac alt mappings without meta
- nnoremap œa :bufdo bd<cr>
- nnoremap œ :bd<cr>
- nnoremap ¬ :bnext<cr>
- nnoremap ˙ :bprevious<cr>
- " Note Alt key mappings on mac without setting meta key
- nnoremap <A-q> :bufdo bd<cr>
- nnoremap <A-d> :bd<cr>
- nnoremap <A-l> :bnext<cr>
- nnoremap <A-h> :bprevious<cr>
- " Useful mappings for managing tabs
- map <leader>tn :tabnew<cr>
- map <leader>td :tabclose<cr>
- " Move between vim tabs better than with gt and gT
- nnoremap <leader>h gT
- nnoremap <leader>l gt
- " Return to last edit position when opening files (You want this!)
- autocmd BufReadPost *
- \ if line("'\"") > 0 && line("'\"") <= line("$") |
- \ exe "normal! g`\"" |
- \ endif
- " Remember info about open buffers on close
- set viminfo^=%
- " marks
- nnoremap <leader>m :marks
- "----------------------------
- """" Plugin Specific """"
- "----------------------------
- " syntastic settings
- let g:syntastic_javascript_checkers = ['jshint']
- " fugitive settings
- nnoremap <leader>ga :Gwrite<CR>
- nnoremap <leader>gmh :diff //2<CR>
- nnoremap <leader>gmt :diff //3<CR>
- nnoremap <leader>gmu :diffupdate<CR>
- " NERDTree settings
- map <leader>\ :NERDTreeToggle<CR>
- let NERDTreeShowHidden=1
- let g:NERDTreeWinSize=40
- let g:NERDTreeAutoDeleteBuffer=1
- set splitright
- let g:NERDTreeWinPos = "left"
- let g:NERDTreeDirArrowExpandable = '+'
- let g:NERDTreeDirArrowCollapsible = '-'
- " yankring settings
- nmap <leader>y :YRShow<CR>
- let g:yankring_replace_n_nkey = '≤' "next paste option
- let g:yankring_replace_n_pkey = '≥' "prev paste option
- " ag settings
- " When you press gv you Ag after the selected text
- vnoremap <silent> gv :call VisualSelection('gv', '')<CR>
- " When you press <leader>r you can search and replace the selected text
- vnoremap <silent> <leader>r :call VisualSelection('replace', '')<CR>
- map <leader>cc :botright cope<cr> " When you search with Ag, display your results in cope by doing:
- map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
- map <leader>n :cn<cr> " To go to the next search result
- map <leader>p :cp<cr> " To go to the previous search results
- map <leader>g :Ag
- let g:ag_results_mapping_replacements={'vertical_split_silent': 's'}
- " buffergator settings
- nnoremap <leader>b :BuffergatorToggle<CR>
- " ctrl-p settings
- let g:ctrlp_map = '<c-p>'
- nmap <leader>c :CtrlP<CR>
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " => Helper functions
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Delete trailing white space on save, useful for Python and CoffeeScript ;)
- func! DeleteTrailingWS()
- exe "normal mz"
- %s/\s\+$//ge
- exe "normal `z"
- endfunc
- function! CmdLine(str)
- exe "menu Foo.Bar :" . a:str
- emenu Foo.Bar
- unmenu Foo
- endfunction
- function! VisualSelection(direction, extra_filter) 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("Ag \"" . 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 '
- endif
- return ''
- endfunction
- " Don't close window, when deleting a buffer
- command! Bclose call <SID>BufcloseCloseIt()
- function! <SID>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 VIM remember position in file after reopen
- if has("autocmd")
- au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
- endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement