""""""""""""""""""""""""" " .vimrc by rabbitear " """"""""""""""""""""""""" " THE HELP: <<========================>> " :help ^n shows what ctrl n does in normal mode " :help i_^n shows what ctrl n does in insert mode " :help c_^n shows what ctrl n does in command mode " :helpgrep " :help The main help screen " ctrl-o Jumps back " BASIC SETUP: <<=====================>> " enter the current millumium set nocompatible " enable syntax and plugins (for netrw) syntax enable filetype plugin on """""""""""""""""""""""""""""""" " KREATORS EXTRA BASIC STUFF " """""""""""""""""""""""""""""""" " folding (fastest to slowest) can be expr, syntax, list, custom set tabstop=4 set shiftwidth=4 set expandtab set foldlevelstart=0 let mapleader = '\' " more general settings set backspace=indent,eol,start " make clipboard more flexable set backup " make backup files set backupdir=~/.vim/tmp/backup " directory to place backup files in set directory=~/.vim/tmp/swap " directory to place swap files in set undodir=~/.vim/tmp/undo " directory to place undo files in set mouse=a " use the mouse everywhere set undofile " make undo possible after the file is closed & reopened set ttimeoutlen=50 " make ESC work faster " some folding at home nnoremap za " SPACE toggles folds vnoremap za " same here ^ nnoremap zO zCzO " make z0 recursively open whatever top-lvl fold we're in. " For gvim, hide all this stuff set guioptions-=m "remove menu bar set guioptions-=T "remove toolbar set guioptions-=r "remove right-hand scroll bar set guioptions-=L "remove left-hand scroll bar " For gvim, hide all this stuff set guioptions-=m "remove menu bar set guioptions-=T "remove toolbar set guioptions-=r "remove right-hand scroll bar set guioptions-=L "remove left-hand scroll bar set encoding=utf-8 " ktr- hopefully view chinese characters set fileencodings=utf-8 " same here ^ " START of WordCount functions " END of WordCount functions " While Writing Papers, Letters, Documents. " use 'gq}' to reformat. set textwidth=72 " automatically reformat to textwidth " ktr: I'm trying to use to toggle wrapping at 72. " set formatoptions+=a " turn on spell checking " setlocal spell spelllang=en_us """""""""""""""""""""""""""""""""""""" " KREATORS EXTRA BASIC STUFF *END* " """""""""""""""""""""""""""""""""""""" """"""""""""""""""" " Folding START " """"""""""""""""""" set foldenable " Turn on folding set foldmethod=marker " Fold on the marker " set foldlevel=100 " Don't autofold anything (but can still fold manually) set foldopen=block,hor,mark,percent,quickfix,tag " what movements openfolds function! MyFoldText() " {{{ let line = getline(v:foldstart) let nucolwidth = &fdc + &number * &numberwidth let windowwidth = winwidth(0) - nucolwidth - 3 let foldedlinecount = v:foldend - v:foldstart " expand tabs into spaces let onetab = strpart(' ', 0, &tabstop) let line = substitute(line, '\t', onetab, 'g') let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount)) let fillcharcount = windowwidth - len(line) - len(foldedlinecount) - 6 return line . ' …' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' ' endfunction " }}} set foldtext=MyFoldText() """"""""""""""""""" " Folding *END* " """"""""""""""""""" """""""""""""""""" " Vim UI START " """""""""""""""""" set background=dark set t_Co=256 if &term =~ '256color' " Disable Background Color Erase (BCE) so that color schemes " work properly when Vim is used inside tmux and GNU screen. " See also http://snk.tuxfamily.org/log/vim-256color-bce.html set t_ut= endif set incsearch " incremental search aka search as you type set hlsearch " highlight search matches set ignorecase " ignore case set smartcase " but when the query starts with upper character be case sensitive set laststatus=2 " always show the status line set lazyredraw " do not redraw while running macros set linespace=0 " don't insert any extra pixel lines between rows set list " show traling listchars set listchars=tab:▸\ ,trail:¬,extends:❯,precedes:❮,nbsp:~ set nostartofline " don't move the cursor to first non-blank character after some commands (:25 e.g.) set novisualbell " don't blink set relativenumber " turn on line numbers set nu set report=0 " tell us when anything is changed set ruler " Always show current positions along the bottom set shortmess=atToOI " shortens messages to avoid 'press a key' prompt set showcmd " show the command being typed set showmode " show current mode set showmatch " show matching brackets set scrolloff=5 " Keep 10 lines (top/bottom) for scope set sidescrolloff=10 " Keep 5 lines at the size "set cursorline " visually mark current line set showbreak=↪ " indicate wrapped line """""""""""""""""" " Vim UI *END* " """""""""""""""""" """""""""""""""""""""""""" " Where Left Off START " """""""""""""""""""""""""" if has("autocmd") " Enable file type detection. " Use the default filetype settings, so that mail gets 'tw' set " to 72, 'cindent' is on in C files, etc. Also load indent files, " to automatically do language-dependent indenting. filetype plugin indent on " Put these in an autocmd group, so that we can delete them easily. augroup vimrcEx au! " For all text files set 'textwidth' to 78 characters. autocmd FileType text setlocal textwidth=78 " When editing a file, always jump to the last known cursor " position. Don't do it when the position is invalid or when " inside an event handler (happens when dropping a file on gvim). " Also don't do it when the mark is in the first line, that is " the default position when opening a file. autocmd BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif augroup END else set autoindent " always set autoindenting on endif " has("autocmd") " For conceal markers. if has('conceal') set conceallevel=2 concealcursor=niv endif """""""""""""""""""""""""" " Where Left Off *END* " """""""""""""""""""""""""" """""""""""""""""""" " NERDtree START " """""""""""""""""""" nnoremap :NERDTreeToggle " F12 toggles file explorer let g:NERDTreeMinimalUI=1 let g:NERDTreeDirArrows=1 let g:NERTreeHighlightCursorLine=1 " if a directory is specified, open NERDtree autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif """""""""""""""""""" " NERDtree *END* " """""""""""""""""""" """""""""""""""""""""""""""""""""" " Enhancements (youtube) START " """""""""""""""""""""""""""""""""" " FINDING FILES: <<===================>> set path+=** " Display all matching files when we tab compete set wildmenu set wildmode=full " from my old vimrc's " NOW WE CAN: " - Hit tab to :find by partial match " - Use * to make it fuzzy " THINGS TO CONSIDER: " - :b lets you autocomplete any open buffer " TAG JUMPING: <<=====================>> " Create the `tags` file (requires ctags) command! MakeTags !ctags -R . " NOW WE CAN: " - Use ^] to jump to tag under cursor " - Use g^] for ambiguous tags (list of tags, globally) " - Use ^t to jump back up the tag stack " THINGS TO CONSIDER: " - This doesn't help if you want a visual list of tags " AUTOCOMPLETE: <<====================>> " The good stuff is documented in |ins-completion| " HIGHLIGHTS: " - ^x^n for JUST this file " - ^x^f for filenames (works with our path trick!) " - will work with absolute paths too. " - ^x^] for tags only " - ^n for anything specified by the 'complete' option " - ^p the reverse of above " NOW WE CAN: " - Use ^n and ^p to go back and forth in the suggestion list " FILE BROWSING: <<===================>> " Tweaks for browsing files let g:netrw_banner=0 " disable annoying nanner let g:netrw_browse_split=4 " open in prior window let g:netrw_altv=1 " open splits to the right let g:netrw_liststyle=3 " tree view let g:netrw_list_hide=netrw_gitignore#Hide() let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+' " NOW WE CAN: " - :edit a folder to open a file browser " - /v/t to open in an h-split/v-split/tab " - check |netrw-browse-maps| for more mappings " - look up the options, can expland and contract trees " SNIPPETS: <<========================>> " Read an empty HTML template and move cursor to title nnoremap ,html :-1read $HOME/.vim/.skeleton.html3jwf>a " NOW WE CAN: " - Take over the world! " (with much fewer keystrokes) " HOW: " nnoremap - Only in normal-mode and no-remap " - when you type ,html it types the string " -1 change the line back one " read read in the file .skeleton.html " enter, goes to normal-mode " 3j go down 3 rows " w go to a word ahead " f> find > " a append " BUILD INTEGRATION: <<===============>> " Steal Mr. Bradley's formatter & add it to our spec_helper " http://philipbradley.net/rspec-info-vim-with-quickfix " Configure the `make` command to run RSpec (for Rails?) "set makeprg=bundle\ exec\ rspec\ --format\ QuickfixFormatter " NOW WE CAN: " - Run :make to run RSpec " - :cl to list errors " - :cc# to jump to error by number " - :cn (next) and :cp (prev) to navigate forward and back " NOTE: " - output needs to be in QuickfixFormat, so vim can read """""""""""""""""""""""""""""""""" " Enhancements (youtube) *END* " """""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""" " PLUG-INS by Vundle START " """""""""""""""""""""""""""""" filetype off " required set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'VundleVim/Vundle.vim' " Vimwiki Plugin 'vimwiki/vimwiki' " ktr: these are probably not needed, and vimwiki_folding is a string "let g:vimwiki_global_ext = 0 "let g:vimwiki_folding = 1 " Status bar is better Plugin 'vim-airline/vim-airline' Plugin 'vim-airline/vim-airline-themes' let g:airline_powerline_fonts = 1 " Comment and Uncomment lines Plugin 'tpope/vim-commentary' " Surrounding parens, brackets, quotes, XML tags, etc. Plugin 'tpope/vim-surround' " Allow plugins maps to use the . repeat. Plugin 'tpope/vim-repeat' " Tmux commands from inside vim, and access to its buffer. Plugin 'tpope/vim-tbone.git' " When using :python, use the virtualenv if there is one Plugin 'plytophogy/vim-virtualenv' " View CSV files Plugin 'chrisbra/csv.vim' " Make tmux have the vim airline colors Plugin 'edkolev/tmuxline.vim' " Help visualize git repositories Plugin 'jreybert/vimagit' " Helps see changes in VCS's Plugin 'mhinz/vim-signify' " Preview markdown files in the browser Plugin 'suan/vim-instant-markdown' let g:instant_markdown_autostart = 1 " The calendar plugin, this one is cool, w/ vimwiki " - \cal vertical calendar " - \caL horizontally calendar " - :Calendar 1991 11 (thats yr: 1991 mon: Nov) Plugin 'mattn/calendar-vim' " ack.vim for 'ag', light weight maybe -ktr Plugin 'mileszs/ack.vim' if executable('ag') let g:ackprg = 'ag --vimgrep' endif " The fuzzy finder, open with Plugin 'kien/ctrlp.vim' " Graph your VIM undo in tree style Plugin 'sjl/gundo.vim.git' nnoremap :GundoToggle " open/save encrypted gnupg files Plugin 'jamessan/vim-gnupg' " Seemlessly navigate: Tmux <=> vim splits. Plugin 'christoomey/vim-tmux-navigator' " Disable tmux navigator when zooming the Vim pane let g:tmux_navigator_disable_when_zoomed = 1 " Write all buffers before navigating from Vim to tmux pane " let g:tmux_navigator_save_on_switch = 1 " Just your friendly neighborhood NERDtree Plugin 'scrooloose/nerdtree' " A colorscheme Plugin 'xoria256.vim' call vundle#end() " required filetype plugin indent on " required """""""""""""""""""""""""""""" " PLUG-INS by Vundle *END* " """""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""" " VIMWIKI SETTINGS, WoooHooo! START " """"""""""""""""""""""""""""""""""""""" au BufRead,BufNewFile *.wiki set filetype=vimwiki autocmd FileType vimwiki nnoremap t :VimwikiToggleListItem " ktr: this doesn't work with the dairy " if no file is specified then open VimWiki. "autocmd StdinReadPre * let s:std_in=1 "autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | execute 'VimwikiIndex' | endif """"""""""""""""""""""""""""""""""""""" " VIMWIKI SETTINGS, WoooHooo! *END* " """"""""""""""""""""""""""""""""""""""" """"""""""""""" " *THE END* " """""""""""""""