Last active
April 24, 2019 13:45
-
-
Save vizjerai/dd9aeb5a719ba4ca40707a715949264b to your computer and use it in GitHub Desktop.
vim configurations
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
" must be set first; prevents maintaining compatibility with Vi | |
set nocompatible | |
" SYSTEM ====================================================================== | |
" keep these necessary files from being littered all over the machine | |
set undodir=~/.vim/undo// | |
set backupdir=~/.vim/backup// | |
set directory=~/.vim/swp// | |
" HELPER FUNCTIONS ============================================================ | |
" source a file if it exists | |
function! SourceIfExists(filename) | |
if filereadable(a:filename) | execute 'source ' . a:filename | endif | |
endfunction | |
" Vundle ====================================================================== | |
" required to begin Vundle | |
filetype off | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" source Vim plugins we've standardized around | |
call SourceIfExists($HOME . '/.vundle') | |
" source local additional plugins | |
call SourceIfExists($HOME . '/.vundle.local') | |
" required to end Vundle | |
call vundle#end() | |
filetype plugin indent on | |
" INPUT ======================================================================= | |
" make Vim more compatible with other filesystems | |
au BufWritePre set nobomb " don't set byte-order-mark on files | |
set encoding=utf-8 " all opened files should be UTF-8 | |
" make Vim behave more like other editors | |
set backspace=indent,eol,start " enable backspacing through whitespace | |
set virtualedit=all " cursor can move past the end of the line | |
set mouse=a " enable mouse reporting/highlighting/scrolling | |
" use the system clipboard as the default register | |
set clipboard=unnamedplus,unnamed | |
" change the default tabs to two spaces | |
set expandtab " use soft-tabs | |
set softtabstop=2 " default twp-space soft tabs | |
set shiftwidth=2 " auto-indent with 2 spaces | |
" NAVIGATION ================================================================== | |
" a leader key convenient in any keyboard layout | |
let mapleader=' ' | |
" shortcuts for working with the quickview window | |
map <leader>cn :cnext<CR> " next item in quickview | |
map <leader>cp :cprevious<CR> " previous item in quickview | |
map <leader>co :copen<CR> " open quickview | |
" navigate split windows via ctrl-h/j/k/l | |
nnoremap <C-J> <C-W>j | |
nnoremap <C-K> <C-W>k | |
nnoremap <C-H> <C-W>h | |
nnoremap <C-L> <C-W>l | |
" generate ctags from within Vim | |
command Ctags !ctags -R | |
" VISUALS ===================================================================== | |
syntax on " enable syntax highlighting | |
set number " show line number on left side | |
set ruler " show column/line # on bottom-right | |
set nowrap " don't wrap lines | |
set laststatus=2 " show statusline at the bottom | |
set showcmd " show partial command input on bottom-right | |
" show invisible charactes | |
set list | |
set listchars=tab:⸘⸘,trail:⸘,extends:»,precedes:« | |
" modify cursor depending on mode | |
let &t_SI = "\<Esc>]50;CursorShape=1\x7" | |
let &t_EI = "\<Esc>]50;CursorShape=0\x7" | |
" shortcuts for common visual changes | |
map <leader>w :set wrap!<CR> " toggle line wrapping | |
map <leader>r :set relativenumber!<CR> " toggle relative/normal line numbers | |
map <leader>b :call ToggleBackground()<CR> " toggle between light/dark backgrounds | |
set guifont=Menlo:h18 " Set font to a reasonable size for GUI clients (eg Macvim) | |
" FILETYPES =================================================================== | |
au BufNewFile,BufRead *.go set filetype=go | |
au BufNewFile,BufRead *.json set filetype=javascript | |
au BufNewFile,BufRead *.md,*.markdown set filetype=markdown | |
au BufNewFile,BufRead *.gemspec,[gG]uardfile,[gG]emfile,[cC]apfile,[rR]akefile,*.ru set filetype=ruby | |
au BufNewFile,BufRead *.slim set filetype=slim | |
au BufNewFile,BufRead *.psql set filetype=sql | |
au BufNewFile,BufRead *.vundle,*.vundle.local set filetype=vim | |
" SEARCH ====================================================================== | |
set hlsearch " highlight search results | |
set incsearch " enable incremental searching | |
set ignorecase " searches are case insensitive... | |
set smartcase " unless they contain a capital letter | |
" center the screen on search results | |
nnoremap n nzz | |
nnoremap N Nzz | |
nnoremap * *zz | |
nnoremap # #zz | |
nnoremap g* g*zz | |
nnoremap g# g#zz |
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
Plugin 'gmarik/Vundle.vim' " vim bundle manager | |
Plugin 'bling/vim-airline' " better status line | |
Plugin 'kien/ctrlp.vim' " fuzzy-finder purely in VimL | |
Plugin 'scrooloose/syntastic' " syntax checking | |
"Plugin 'scrooloose/nerdtree' " better file navigation | |
Plugin 'tpope/vim-surround' " deal with (),<>, etc | |
Plugin 'tpope/vim-fugitive' " so much Git integration | |
Plugin 'tpope/vim-commentary' " easily comment lines/blocks | |
Plugin 'tpope/vim-rails' " so many Rails helpers | |
Plugin 'tpope/vim-endwise' " block endings for several languages | |
Plugin 'tpope/vim-repeat' " Enables repeate (.) usage for plugins such as vim-surround | |
Plugin 'terryma/vim-multiple-cursors' " Sublime style multiple cursors! Mostly. Ctrl+n to use | |
Plugin 'godlygeek/tabular' " Align tables, hashes, etc. programatically | |
Plugin 'mustache/vim-mustache-handlebars' " highlighting for mustache / handlebars | |
Plugin 'ervandew/supertab' " configurable tab autocompletion | |
Plugin 'mileszs/ack.vim' " Use Ack from vim | |
Plugin 'slim-template/vim-slim' " Slim template hightlighting |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment