" 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') " Use syntax highlighting if !exists('g:syntax_on') syntax enable endif " 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 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 'shiftwidth' if supported else set 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 " 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') set formatoptions+=j endif " Keep more command and search history set history=500 " Don't assume I'm editing C; let the filetype set this set 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 " Don't allow setting options via buffer content set nomodeline " Treat numbers with a leading zero as decimal, not octal set nrformats-=octal " Don't show startup splash screen (I donated) set shortmess+=I " Give me a bit longer to complete mappings set timeoutlen=3000 " Clear default 'comments' value, let the filetype handle it if has('comments') set comments= endif " Highlight settings for search if has('extra_search') set hlsearch " Highlight completed searches set incsearch " Show matches as I type endif " More sensible language-agnostic setting for gf/: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 if exists('+breakindent') set breakindent " Indent wrapped lines, if supported endif endif " Don't store any options or mappings in sessions if has('mksession') set sessionoptions-=localoptions set sessionoptions-=options 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) " Map double Ctrl-K in insert mode to search digraph names imap (DigraphSearch) " Remap normal space to scroll down a page, backspace up a page nnoremap nnoremap " 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 " \= runs the whole buffer through =, preserving position nnoremap = :call vimrc#Anchor('1G=G') " \+ runs the whole buffer through gq, preserving position nnoremap + :call vimrc#Anchor('1GgqG') " \. runs the configured make program to location list nnoremap . :lmake! " \DEL deletes the current buffer nnoremap :bdelete " \INS edits a new buffer nnoremap :enew " Source any .vim files from ~/.vim/config runtime! config/*.vim