Created
August 18, 2014 09:50
-
-
Save wazery/c683ffcb894045e9b5c4 to your computer and use it in GitHub Desktop.
My .vimrc configurations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required | |
Plugin 'gmarik/Vundle.vim' | |
Plugin 'wincent/Command-T' | |
" The following are examples of different formats supported. | |
" Keep Plugin commands between vundle#begin/end. | |
Plugin 'kshenoy/vim-signature' | |
Plugin 'vim-scripts/ScrollColors' | |
" Tim Pope's awesome Rails integration plugin | |
Plugin 'tpope/vim-rails' | |
" Tim Pope's colorscheme that is well integrated with his Rails plugin | |
Plugin 'tpope/vim-vividchalk' | |
Plugin 'garbas/vim-snipmate' | |
Plugin 'vim-scripts/tComment' | |
Plugin 'vim-scripts/Auto-Pairs' | |
" Plugin 'mhinz/vim-startify' | |
Plugin 'terryma/vim-multiple-cursors' | |
Plugin 'regedarek/ZoomWin' | |
Plugin 'tpope/vim-fugitive' | |
Plugin 'editorconfig/editorconfig-vim' | |
" 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 | |
" | |
" Brief help | |
" :PluginList - list configured plugins | |
" :PluginInstall(!) - install (update) plugins | |
" :PluginSearch(!) foo - search (or refresh cache first) for foo | |
" :PluginClean(!) - confirm (or auto-approve) removal of unused plugins | |
" | |
" see :h vundle for more details or wiki for FAQ | |
" Put your non-Plugin stuff after this line | |
" To install plugins write | |
" Vim +PluginInstall +qall in your terminal or :PluginInstall in Vim | |
syntax on | |
set cf " Enable error files & error jumping. | |
set clipboard+=unnamed " Yanks go on clipboard instead. | |
set history=256 " Number of things to remember in history. | |
set autowrite " Writes on make/shell commands | |
set ruler " Ruler on | |
set nu " Line numbers on | |
set nowrap " Line wrapping off | |
set scrolloff=3 | |
set timeoutlen=250 " Time to wait after ESC (default causes an annoying delay) | |
set shell=/bin/sh | |
colorscheme molokai " Uncomment this to set a default theme | |
" " Formatting (some of these are for coding in C and C++) | |
set ts=2 " Tabs are 2 spaces | |
set bs=2 " Backspace over everything in insert mode | |
set shiftwidth=2 " Tabs under smart indent | |
set nocp incsearch | |
set cinoptions=:0,p0,t0 | |
set cinwords=if,else,while,do,for,switch,case | |
set formatoptions=tcqr | |
set cindent | |
set autoindent | |
set smarttab | |
set expandtab | |
" Set the tag file search order | |
set tags=./tags; | |
" Use ack instead of grep | |
set grepprg=ack | |
" Fuzzy finder: ignore stuff that can't be opened, and generated files | |
let g:fuzzy_ignore = "*.png;*.PNG;*.gif;*.GIF;*.jpg;*.JPG;vender/**;coverage/**;tmp/**;rdoc/**" | |
" Highlight the status line | |
highlight StatusLine ctermfg=grey ctermbg=black | |
" Make the autocompletion readable | |
highlight PmenuSel ctermfg=white ctermbg=black | |
set wildmenu | |
set wildmode=longest,list | |
" Highlight the current line | |
set cursorline | |
hi CursorLine term=bold cterm=bold guibg=Grey40 | |
"hi CursorLine ctermbg=8 ctermfg=15 "8 = dark gray, 15 = white | |
"hi Cursor ctermbg=15 ctermfg=8 | |
" Add the g flag to search/replace by default | |
set gdefault | |
" Highlight searches | |
set hlsearch | |
" Ignore case of searches | |
set ignorecase | |
" Highlight dynamically as pattern is typed | |
set incsearch | |
" The following optional commands are helpful but require explicit creation of directories and files: | |
" Backups & Files | |
" Centralize backups, swapfiles and undo history | |
if exists("&undodir") | |
set undodir=~/.vim/undo | |
endif | |
set backupdir=~/.vim/backup// | |
set directory=~/.vim/swap// | |
set undodir=~/.vim/undo// | |
" Visual | |
set showmatch " Show matching brackets. | |
set mat=5 " Bracket blinking. | |
set nolist | |
" Show the current mode | |
set showmode | |
" Show $ at end of line and trailing space as ~ | |
set lcs=tab:\ \ ,eol:$,trail:~,extends:>,precedes:< | |
set novisualbell " No blinking . | |
set noerrorbells " No noise. | |
set laststatus=2 " Always show status line. | |
" Don't reset cursor to start of line when moving around. | |
set nostartofline | |
" gvim specific | |
set mousehide " Hide mouse after chars typed | |
set mouse=a " Mouse in all modes | |
set mouse=niv | |
" Enable copying to clipboard using CTRL + C | |
map <C-c> y:e ~/clipsongzboard<CR>P:w !pbcopy<CR><CR>:bdelete!<CR> | |
" Remove last search highlighting, when hitting return | |
nnoremap <CR> :set hlsearch!<cr> | |
" Remove Macvim right, and lenft scrollbar | |
set guioptions-=r | |
set guioptions-=L | |
" Set the guifont | |
set guifont=Menlo:h14 | |
" To allow jump to files without saving | |
set hidden | |
" Change default leader key to , | |
let mapleader = ',' | |
" Diff tab management: open the current git diff in a tab | |
command! GdiffInTab tabedit %|vsplit|Gdiff | |
nnoremap <leader>d :GdiffInTab<cr> | |
nnoremap <leader>D :tabclose<cr> | |
" OPEN FILES IN DIRECTORY OF CURRENT FILE | |
cnoremap %% <C-R>=expand('%:h').'/'<cr> | |
map <leader>e :edit %% | |
map <leader>v :view %% | |
" Edit routes | |
command! Rroutes :RE config/routes.rb | |
command! RTroutes :RTedit config/routes.rb | |
command! Rgem :RE Gemfile | |
" Insert a pry code | |
command Pry :normal i binding.pry<ESC> | |
command EPry :normal i <% binding.pry %><ESC> | |
" Easy switching to full screen in split window | |
map <leader>f :tab split<cr> | |
map <leader>c :tab close<cr> | |
" Disable the tooltips of vim-ruby plugin | |
" Insert new line without entering insert mode | |
" imap <C-m> <esc>o | |
" MAPS TO JUMP TO SPECIFIC COMMAND-T TARGETS AND FILES | |
map <leader>gr :topleft :split config/routes.rb<cr> | |
function! ShowRoutes() | |
" Requires 'scratch' plugin | |
:topleft 100 :split __Routes__ | |
" Make sure Vim doesn't write __Routes__ as a file | |
:set buftype=nofile | |
" Delete everything | |
:normal 1GdG | |
" Put routes output in buffer | |
:0r! rake -s routes | |
" Size window to number of lines (1 plus rake output length) | |
:exec ":normal " . line("$") . "_ " | |
" Move cursor to bottom | |
:normal 1GG | |
" Delete empty trailing line | |
:normal dd | |
endfunction | |
map <leader>gR :call ShowRoutes()<cr> | |
" MULTIPURPOSE TAB KEY | |
" Indent if we're at the beginning of a line. Else, do completion. | |
function! InsertTabWrapper() | |
let col = col('.') - 1 | |
if !col || getline('.')[col - 1] !~ '\k' | |
return "\<tab>" | |
else | |
return "\<c-p>" | |
endif | |
endfunction | |
inoremap <tab> <c-r>=InsertTabWrapper()<cr> | |
" RENAME CURRENT FILE | |
function! RenameFile() | |
let old_name = expand('%') | |
let new_name = input('New file name: ', expand('%'), 'file') | |
if new_name != '' && new_name != old_name | |
exec ':saveas ' . new_name | |
exec ':silent !rm ' . old_name | |
redraw! | |
endif | |
endfunction | |
map <leader>n :call RenameFile()<cr> | |
" Jum to last cursor position unlessit's invalid or in an event handler | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal g'\"" | | |
\ endif | |
" Weaning myself off the arrow keys, | |
noremap <Up> <nop> | |
noremap <Down> <nop> | |
noremap <Left> <nop> | |
noremap <Right> <nop> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment