" 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 its end, but " you'll get errors for some of the leader maps. " Undo anything the operating system's vimrc may have broken runtime system.vim " Load filetype settings, plugins, and maps if has('autocmd') let g:maplocalleader = '\\' filetype plugin indent on endif " Options dependent on the syntax feature if has('syntax') && !exists('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 setglobal autoindent " Use indent of previous line on new lines setglobal expandtab " Use spaces instead of tabs setglobal shiftwidth=4 " Indent with four spaces " Spaces to insert on Tab key insert if v:version > 703 || v:version == 703 && has('patch693') setglobal softtabstop=-1 " Refer to 'shiftwidth' if supported else setglobal softtabstop=4 " Otherwise just four spaces endif " Let me backspace over pretty much anything 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 " 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 if exists('+esckeys') " Not in Neovim set noesckeys endif " Delete comment leaders when joining lines, if supported if v:version > 703 || v:version == 703 && has('patch541') setglobal formatoptions+=j endif " Keep more command and search history set history=500 " Don't assume I'm editing C; let the filetype set this setglobal include= " Don't join lines with two spaces at the end of sentences set nojoinspaces " Don't show a statusline if there's only one window if has('nvim') " Neovim changed the default to 2 set laststatus=1 endif " Don't redraw the screen during batch execution set lazyredraw " Define extra 'list' display 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 if v:version >= 700 set listchars+=nbsp:+ " Non-breaking spaces endif " Add angle brackets to pairs of matched characters setglobal matchpairs+=<:> " Don't allow setting options via buffer content setglobal nomodeline " Treat numbers with a leading zero as decimal, not octal setglobal nrformats-=octal " Abbreviate some more regularly displayed messages set shortmess+=I " Don't show startup splash screen set shortmess+=m " [Modified] -> [+] set shortmess+=r " [readonly] -> [RO] set shortmess+=w " written -> [w], appended -> [a] " Clear default 'comments' value, let the filetype handle it if has('comments') setglobal comments= 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 " More sensible language-agnostic setting for gf/:find if has('file_in_path') setglobal 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') setglobal linebreak " Break lines at word boundaries set showbreak=... " Prefix wrapped rows with three dots if exists('+breakindent') setglobal breakindent " Indent wrapped lines, if supported 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 if exists('+wildignorecase') set wildignorecase " Case insensitive, if supported endif endif " New windows go below or to the right of a split if has('windows') set splitbelow if has('vertsplit') set splitright endif endif " Stack normal/visual/select Ctrl-L to clear search highlight nnoremap :nohlsearch vnoremap :nohlsearchgv " Remap insert Ctrl-C to undo the escaped insert operation " Default to not-quite-correct vim-tiny-compatible map if no plugin inoremap InsertCancel u imap InsertCancel " Remap normal J to stay in place while joining lines " Default to not-quite-correct vim-tiny-compatible map if no plugin nnoremap FixedJoin mzJ`z nmap J FixedJoin " Remap normal/visual space to scroll down a page, backspace up nnoremap nnoremap if v:version >= 700 xnoremap xnoremap endif " Remap normal/visual & to preserve substitution flags nnoremap & :&& if v:version >= 700 xnoremap & :&& endif " Cycle through argument list nnoremap [a :previous nnoremap ]a :next " Cycle through buffers nnoremap [b :bprevious nnoremap ]b :bnext " Cycle through quicklist/:helpgrep items nnoremap [c :cprevious nnoremap ]c :cnext " Cycle through location list items nnoremap [l :lprevious nnoremap ]l :lnext " Cycle through tabs nnoremap [t :tabprevious nnoremap ]t :tabnext " Insert blank lines around current line nmap [ PutBlankLinesAbove nmap ] PutBlankLinesBelow " Normal leader maps; use not for 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 'cursorline' nnoremap c :setlocal cursorline! cursorline? " \C toggles 'cursorcolumn' nnoremap C :setlocal cursorcolumn! cursorcolumn? " \d inserts the local date (POSIX date) nnoremap d :read !date " \D inserts the UTC date (POSIX date) nnoremap D :read !date -u " \e forces a buffer to be editable nnoremap e :setlocal modifiable noreadonly " \f shows the current 'formatoptions' at a glance nnoremap f :setlocal formatoptions? " \g changes directory to the current file's location nnoremap g :cd %:h:pwd " \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 :buffers:buffer " \k shows my marks nnoremap k :marks " \l toggles showing tab, end-of-line, and trailing whitespace nnoremap l :setlocal list! list? " \m shows all maps nnoremap m :map " \M shows buffer-local maps nnoremap M :map " \n toggles line numbers nnoremap n :setlocal number! number? " \N toggles 'ruler' nnoremap N :set ruler! ruler? " \o opens a line below in paste mode nmap o PasteOpenBelow " \o opens a line above in paste mode nmap O PasteOpenAbove " \p toggles paste mode nnoremap p :set paste! paste? " \q formats the current paragraph nnoremap q gqap " \r reloads .vimrc nnoremap r :source $MYVIMRC " \R reloads filetype nnoremap R :doautocmd filetypedetect BufRead " \s toggles spell checking nnoremap s :setlocal spell! spell? " \t shows current filetype nnoremap t :setlocal filetype? " \T clears filetype (follow with \R) nnoremap T :setlocal filetype= " \u sets US English spelling (compare \z) nnoremap u :setlocal spelllang=en_us " \v shows all global variables nnoremap v :let g: v: " \V shows all local variables nnoremap V :let b: t: w: " \w toggles wrapping nnoremap w :setlocal wrap! wrap? " \x strips trailing whitespace via a custom plugin nmap x StripTrailingWhitespace " \y shows all registers nnoremap y :registers " \z sets NZ English spelling (compare \u) nnoremap z :setlocal spelllang=en_nz " \DEL deletes the current buffer nnoremap :bdelete " \INS edits a new buffer nnoremap :enew " Source any .vim files from ~/.vim/config runtime! config/*.vim " Flag that we loaded, tell the user if we reload if 1 if exists('g:loaded_vimrc') echomsg 'Reloaded vimrc: '.$MYVIMRC endif let g:loaded_vimrc = 1 endif