" An example for a vimrc file. " " Maintainer: Bram Moolenaar " Last change: 2001 Jul 18 " " To use it, copy it to " for Unix and OS/2: ~/.vimrc " for Amiga: s:.vimrc " for MS-DOS and Win32: $VIM\_vimrc " for OpenVMS: sys$login:.vimrc " By Andy Bennett, 19/8/2002, 20:26 " Do not process this file for versions of vim < 6.1 if version >= 601 " When started as "evim", evim.vim will already have done these settings. if v:progname =~? "evim" finish endif " Use Vim settings, rather then Vi settings (much better!). " This must be first, because it changes other options as a side effect. set nocompatible " allow backspacing over everything in insert mode set backspace=indent,eol,start set autoindent " always set autoindenting on if has("vms") set nobackup " do not keep a backup file, use versions instead else set backup " keep a backup file endif set history=50 " keep 50 lines of command line history set ruler " show the cursor position all the time set showcmd " display incomplete commands set incsearch " do incremental searching " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries " let &guioptions = substitute(&guioptions, "t", "", "g") " Don't use Ex mode, use Q for formatting map Q gq " Make p in Visual mode replace the selected text with the "" register. vnoremap p :let current_reg = @"gvs=current_reg " This is an alternative that also works in block mode, but the deleted " text is lost and it only works for putting the current register. "vnoremap p "_dp " Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif " Only do this part when compiled with support for autocommands. 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 " 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). autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif " Be sure to reapply our colour scheme preferences after every time a colour " scheme is loaded. " From https://gist.github.com/romainl/379904f91fa40533175dfaec4c833f2f " Andy Bennett, 2020/01/03, 19:05 function! MyHighlights() abort hi Comment term=bold ctermfg=grey guifg=grey gui=bold endfunction augroup MyColors autocmd! autocmd ColorScheme * call MyHighlights() augroup END endif " has("autocmd") " By Andy Bennett, 28/6/2002, 21:36 if &t_Co > 1 syntax enable endif " By Andy Bennett, 19/8/2002, 20:32 " Do not process this file for versions of vim < 6.1 endif " By Andy Bennett " Processing for vim 5.0 if version == 500 set nocompatible set autoindent set backup set history=50 set ruler set showcmd set incsearch map Q gq vnoremap p :let current_reg = @"gvs=current_reg if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif endif hi Comment term=bold ctermfg=grey guifg=grey gui=bold " Andy Bennett, 28/12/2002, 21:31 hi Normal guibg=black hi Normal guifg=white " Andy Bennett, 23/12/2003, 21:23 set showmatch " Match braces / parentheses "set tabstop=2 "set shiftwidth=2 " Andy Bennett, 29/6/2003, 22:35 set cindent " Auto indenting set comments=sl:/*,mb:\ *,elx:\ */ " Auto comments " Andy Bennett, 27/2/2005, 21:06. From Dave Jones (davej@redhat.com) on git " mailing list. highlight RedundantSpaces term=standout ctermbg=red guibg=red match RedundantSpaces /\s\+$\| \+\ze\t/ " Andy Bennett, 4/10/2005, 10:30 set mouse=a " Andy Bennett, 21/10/2005, 11:34 set wildmode=longest,list " F2 inserts an li imap
  • hhhhi map o
  • hhhhi " fix indenting on current line & move to end imap == map == " Sort out a {} block imap {} {}O " Andy Bennett, 8/11/2005, 14:31 " Search for tags up the directory tree. set tags=tags;/ map t g " Andy Bennett 13/6/2006 16:32 " Set preview window height and make it stay the same when windows are opened " and closed set previewheight=5 set winfixheight set noequalalways " Preview the tag under the cursor if the cursor stays there for a little " while "au! CursorHold *.[ch] nested exe "silent! psearch " . expand("") :au! CursorHold *.[ch] nested call PreviewWord() :func PreviewWord() : if &previewwindow " don't do this in the preview window : return : endif : let w = expand("") " get the word under cursor : if w =~ '\a' " if the word contains a letter : : " Delete any existing highlight before showing another tag : silent! wincmd P " jump to preview window : if &previewwindow " if we really get there... : match none " delete existing highlight : wincmd p " back to old window : endif : : " Try displaying a matching tag for the word under the cursor : try : exe "ptag " . w : catch : return : endtry : : silent! wincmd P " jump to preview window : if &previewwindow " if we really get there... : if has("folding") : silent! .foldopen " don't want a closed fold : endif : call search("$", "b") " to end of previous line : let w = substitute(w, '\\', '\\\\', "") : call search('\<\V' . w . '\>') " position cursor on match : " Add a match highlight to the word at this position : hi previewWord term=bold ctermbg=green guibg=green : exe 'match previewWord "\%' . line(".") . 'l\%' . col(".") . 'c\k*"' : wincmd p " back to old window : endif : endif :endfun " Andy Bennett 16/4/2008 11:38 " Case insensitive search if no capitals in search string set ignorecase smartcase " Andy Bennett 16/4/2008 11:38 " Switch on spell checking. z= to see options, zg to add to dict. set spelllang=en_gb set spellfile=~/.vim/spell.en.utf-8.add "set spell " Andy Bennett, 5/5/2009, 17:08 set linebreak " Andy Bennett, 2011/11/15, 17:50 " Map [{ and [} to [( and [) respectively for scheme files so that things work " the same as for C files. Also [{ is far easier to key than [(. au FileType scheme,lisp,art map [{ [( au FileType scheme,lisp,art map [} [) " Andy Bennett, 2013/05/29, 10:05 " set tw=76 " use gq to reflow selected text. " Highlight all characters past 76 columns: "augroup vimrc_autocmds " autocmd BufEnter * highlight OverLength ctermbg=darkgrey guibg=#592929 " autocmd BufEnter * match OverLength /\%76v.*/ "augroup END " Andy Bennett, 2014/04/17 12:27 " Based on a list by fIorz in #chicken set lispwords+=define-class,define-method,match,and-let*,let-values,let*-values,match-let*,match-let,let-location,if-let,if-let* " 2018/07/12 set lispwords+=define-in-transaction,lambda-in-transaction " 2019/01/05 set lispwords+=sequence* " 2019/01/22 set lispwords+=lambda-in-savepoint " 2019/01/31 set lispwords+=parameterize " 2019/02/07 au FileType scheme,lisp,art set nocindent set lispwords+=syntax-rules " 2019/06/27 set lispwords+=define-for-syntax,begin-for-syntax