Created
October 19, 2015 00:10
-
-
Save waldofe/e1e798d65757713b1757 to your computer and use it in GitHub Desktop.
basic vimrc
This file contains 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
" Some config came from: http://vim.wikia.com/wiki/Example_vimrc | |
" | |
" Attempt to determine the type of a file based on its name and possibly its | |
" contents. Use this to allow intelligent auto-indenting for each filetype, | |
" and for plugins that are filetype specific. | |
filetype indent plugin on | |
" Tabs basic configuration. | |
set tabstop=2 softtabstop=2 shiftwidth=2 expandtab smarttab | |
" Enable syntax highlighting | |
syntax on | |
" Highlight searches (use <C-L> to temporarily turn off highlighting; see the | |
" mapping of <C-L> below) | |
set hlsearch | |
" Removes trailing spaces automatically | |
autocmd BufWritePre *.rb :%s/\s\+$//e | |
" Use case insensitive search, except when using capital letters | |
set ignorecase | |
set smartcase | |
" When opening a new line and no filetype-specific indenting is enabled, keep | |
" the same indent as the line you're currently on. Useful for READMEs, etc. | |
set autoindent | |
" Stop certain movements from always going to the first character of a line. | |
" While this behaviour deviates from that of Vi, it does what most users | |
" coming from other editors would expect. | |
set nostartofline | |
" Display the cursor position on the last line of the screen or in the status | |
" line of a window | |
set ruler | |
" Always display the status line, even if only one window is displayed | |
set laststatus=2 | |
" Instead of failing a command because of unsaved changes, instead raise a | |
" dialogue asking if you wish to save changed files. | |
set confirm | |
" Use visual bell instead of beeping when doing something wrong | |
set visualbell | |
" Display line numbers on the left | |
set number | |
" Map <C-L> (redraw screen) to also turn off search highlighting until the | |
" next search | |
nnoremap <C-L> :nohl<CR><C-L> | |
" Allow backspacing over autoindent, line breaks and start of insert action | |
set backspace=indent,eol,start | |
" Vundle setup | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Plugin 'gmarik/Vundle.vim' | |
" FZF setup | |
Plugin 'junegunn/fzf' | |
" Searching | |
Plugin 'rking/ag.vim' | |
" Whitespace colorizing | |
Plugin 'ntpeters/vim-better-whitespace' | |
" JS syntax highlightining and indentation improvements | |
Plugin 'pangloss/vim-javascript' | |
Plugin 'scrooloose/nerdtree' | |
call vundle#end() | |
set rtp+=~/.fzf | |
nnoremap <c-p> :FZF<cr> | |
" Map vimrc editing / saving | |
nmap <leader>vr :sp $MYVIMRC<cr> | |
map <leader>T: :Tabularize /:\zs<cr> | |
nmap <leader>so :source $MYVIMRC<cr> | |
" File deleting maps | |
nnoremap rm :call delete(expand('%')) \| bdelete!<CR> | |
" Edit the db/schema.rb Rails file in a split | |
nmap <leader>sc :split db/schema.rb<cr> | |
" Tabs configurations | |
" ------------------------ | |
for tab_number in [1, 2, 3, 4, 5, 6] | |
execute 'map <silent> <C-w>' . tab_number . ' :tabnext ' . tab_number . '<cr>' | |
endfor | |
nnoremap <leader>wn :tabnew<cr> | |
" Delete trailing white space when saving | |
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
au BufWrite * :call DeleteTrailingWS() | |
" Red extra whitespace | |
highlight ExtraWhitespace ctermbg=red | |
" Running ag | |
set runtimepath^=~/.vim/bundle/ag | |
" Rename file function (removing the old one) | |
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> | |
" Nerdtree toggling | |
map <C-n> :NERDTreeToggle<CR> | |
" shortcut for background access | |
nnoremap <leader>b :!fg<cr> | |
" clipboard copy | |
vmap <leader>co :w !pbcopy<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment