" Tom Ryder (tejr)'s vimrc: " " This file is not truly self-contained; it should run without errors on its " own without the accompanying plugins to which it refers near the end of this " file, but you'll get errors for some of the leader maps, for example. " Load filetype settings and plugins if has('autocmd') filetype plugin indent on endif " Options dependent on the syntax feature if has('syntax') && !has('g:syntax_on') " Use syntax highlighting syntax enable " Use my colorscheme if using the GUI or if we have 256 colors if has('gui_running') || &t_Co >= 256 silent! colorscheme sahara endif " If not sahara, then default with dark background if !exists('g:colors_name') set background=dark endif endif " The all-important default indent settings; filetypes to tweak set autoindent " Use indent of previous line on new lines set expandtab " Use spaces instead of tabs set shiftround " Round indenting to multiples of 'shiftwidth' set shiftwidth=4 " Indent with four spaces " Spaces to insert on Tab key insert if v:version > 703 || v:version == 703 && has('patch693') set softtabstop=-1 " Refer to 'shifwidth' if supported else set softtabstop=4 " Otherwise just four spaces endif " Let me backspace over pretty much anything set backspace= set backspace+=eol " Line breaks set backspace+=indent " Spaces from 'autoindent' set backspace+=start " The start of current insertion " Never use any kind of bell, visual or not if exists('+belloff') set belloff=all else set visualbell t_vb= endif " Clear default comment string, let the filetype handle it set comments= " How to deal with lines wrapping beyond the last screen row if v:version > 704 || v:version == 704 && has('patch2109') set display=truncate " Show '@@@' on the last line, if supported else set display=lastline " Just let it run off the screen if not endif " Don't wait for a key after Escape in insert mode set noesckeys " Delete comment leaders when joining lines, if supported if v:version > 703 || v:version == 703 && has('patch541') set formatoptions+=j endif " Don't join lines with two spaces at the end of sentences set nojoinspaces " Don't redraw the screen during batch execution set lazyredraw " Define list characters set listchars+=extends:> " Unwrapped text to screen right set listchars+=precedes:< " Unwrapped text to screen left set listchars+=tab:>- " Tab characters, preserve width set listchars+=trail:_ " Trailing spaces " Add angle brackets to pairs of matched characters set matchpairs+=<:> " Don't allow setting options via buffer content set nomodeline " Treat numbers with a leading zero as decimal, not octal set nrformats-=octal " Always tell me the number of lines changed by a command set report=0 " Abbreviate some of the regularly displayed messages set shortmess= set shortmess+=f " (file 3 of 5) -> (3 of 5) set shortmess+=i " [Incomplete last line] -> [noeol] set shortmess+=I " Don't show startup splash screen set shortmess+=l " 999 lines, 888 characters -> 999L, 888C set shortmess+=m " [Modified] -> [+] set shortmess+=n " [New File] -> [New] set shortmess+=o " Don't stack file writing messages set shortmess+=O " Don't stack file reading messages set shortmess+=r " [readonly] -> [RO] set shortmess+=t " Truncate file message at start if too long set shortmess+=T " Truncate other message in middle if too long set shortmess+=w " written -> [w], appended -> [a] set shortmess+=x " [dos format] -> [dos] " Show my current position in the status bar if has('cmdline_info') set ruler endif " Highlight settings for search if has('extra_search') set hlsearch " Highlight completed searches... nohlsearch " ...but clear it on startup or after re-sourcing set incsearch " Show matches as I type endif " Use whole tree from current directory for :find if has('file_in_path') set path+=** endif " Don't load GUI menus; set here before GUI starts if has('gui_running') set guioptions+=M endif " Line break behaviour settings for 'wrap' if has('linebreak') set linebreak " Break lines at word boundaries set showbreak=... " Prefix wrapped rows with three dots " Indent wrapped lines, if supported if exists('+breakindent') set breakindent endif endif " Let me move beyond buffer text in visual block mode if has('virtualedit') set virtualedit+=block endif " Nicer completion for command mode if has('wildmenu') set wildmenu " Use wildmenu set wildmode=list:longest " Tab press completes and lists " Complete files without case sensitivity, if supported if exists('+wildignorecase') set wildignorecase endif endif " New windows go below or to the right of a split if has('windows') set splitbelow if has('vertsplit') set splitright endif " Get rid of visually noisy folding characters if has('folding') let &fillchars = 'diff: ,fold: ,vert: ' endif endif " Rebind insert Ctrl-C to undo the current insert operation inoremap u " Rebind normal to scroll down a page nnoremap " Rebind normal & to preserve substitution flags nnoremap & :&& " Stack normal Ctrl-L to clear search highlighting before redraw nnoremap :nohlsearch " Cycle through argument list nnoremap [a :previous nnoremap ]a :next " Cycle through buffers nnoremap [b :bprevious nnoremap ]b :bnext " Cycle through quicklist items (more often :helpgrep results) nnoremap [c :cprevious nnoremap ]c :cnext " Cycle through location list items nnoremap [l :lprevious nnoremap ]l :lnext " Insert blank lines above and below current line nmap [ PutBlankLinesAbove nmap ] PutBlankLinesBelow " Swap buffer line vs screen row motions nnoremap j gj nnoremap gj j nnoremap k gk nnoremap gk k " Remap Y to yank to end of line (consistent with C, D) nnoremap Y y$ " ZA unconditionally writes all buffers nnoremap ZA :wall! " ZW unconditionally writes current buffer nnoremap ZW :write! " Custom digraphs if has('digraphs') digraph ./ 8230 " Ellipsis (HORIZONTAL ELLIPSIS U+2026) digraph %% 8984 " Mac command key (PLACE OF INTEREST SIGN U+2318) digraph 8: 9731 " Snowman (SNOWMAN U+2603) endif " Use different keys for global and local leaders for plugins if 1 let g:mapleader = '\' let g:maplocalleader = '_' endif " Leader mappings below; use a literal backslash rather than so that " the non-plugin mappings work on vim-tiny " \a toggles 'formatoptions' 'a' flag using a plugin nnoremap \a :ToggleOptionFlagLocal formatoptions a " \b toggles copy-pasteable linebreak settings nmap \b CopyLinebreakToggle " \c toggles 'cursorcolumn', \C toggles 'cursorline' nnoremap \c :set cursorcolumn! cursorcolumn? nnoremap \C :set cursorline! cursorline? " Current date and time insertion commands, requiring POSIX date(1) if has('unix') " \d inserts the local date nnoremap \d :read !date " \D inserts the UTC date nnoremap \D :read !date -u endif " \f shows the current 'formatoptions' at a glance nnoremap \f :set formatoptions? " \h toggles highlighting search results nnoremap \h :set hlsearch! hlsearch? " \i toggles showing matches as I enter my pattern nnoremap \i :set incsearch! incsearch? " \j jumps to buffers (jetpack) nnoremap \j :ls:buffer " \l toggles showing tab, end-of-line, and trailing whitespace nnoremap \l :set list! list? " \n toggles line numbers nnoremap \n :set number! number? " \o and \O open 'pasted insert' lines nmap \o PasteOpenBelow nmap \O PasteOpenAbove " \p toggles paste mode nnoremap \p :set paste! paste? " \r reloads .vimrc nnoremap \r :source $MYVIMRC " \s toggles spell checking nnoremap \s :setlocal spell! spell? " \t shows current filetype nnoremap \t :set filetype? " \u sets US English spelling (compare \z) nnoremap \u :setlocal spelllang=en_us spelllang? " \w toggles wrapping nnoremap \w :set wrap! wrap? " \x strips trailing whitespace via a custom plugin nmap \x StripTrailingWhitespace " \z sets NZ English spelling (compare \u) nnoremap \z :setlocal spelllang=en_nz spelllang? " Add packaged matchit.vim, if supported if has('packages') packadd! matchit endif " Disable core plugins I don't use if 1 " I manage plugins myself with Git and a Makefile let g:loaded_getscriptPlugin = 1 let g:loaded_vimballPlugin = 1 " Vim is the wrong tool for reading archives or compressed text let g:loaded_gzip = 1 let g:loaded_tarPlugin = 1 let g:loaded_zipPlugin = 1 " I prefer filtering text with Unix tools let g:loaded_logiPat = 1 " The shell, tab completion, and 'wildmenu' are good enough let g:loaded_netrwPlugin = 1 " I don't use Vim servers let g:loaded_rrhelper = 1 " I don't need extra spelling files let g:loaded_spellfile_plugin = 1 endif " Source any .vim files from ~/.vim/config runtime! config/*.vim