" To copy a buffer to clipboard: :%y+ " " Note: put cursor on a purple word and press K for help " Experimental stuff "---------------------------------------------------------------------- " Plugins " Source the sketching script for gvim "source d:/don/.vim/plugin/sketch.vim "noremap :call ToggleSketch() "---------------------------------------------------------------------- "set virtualedit=all set linebreak set breakat=" ^I!@*-+;:,./?" set showbreak="\0376" set display=lastline set background=dark set printoptions=number:y " Turn off the menu and toolbar in the GUI set guioptions-=m set guioptions-=T " Where to search for plugins, syntax files, etc. set runtimepath=$VIMRUNTIME,d:/don/.vim autocmd BufEnter * lcd %:p:h " Always cd to a file's directory " Search path for gf command set path=,,..,d:/donp,c:/bin/mingw/include,c:/bin/mingw/include/sys,c:/bin/mingw/include/c++/3.2 " Show at least n lines above/below line with cursor set scrolloff=0 set updatecount=100 " After 100 characters, write swap file to disk set whichwrap=bshl~][ " Which characters are allowed to wrap set shell=c:/cygwin/usr/bin/bash\ --login set nowarn " Don't warn when running a shell command with a changed buffer set wildignore=*.o,*.obj " Files to ignore in wildcard expansion set wildmenu " Give menu for multiple file completion candidates set wildmode=longest:full set exrc " Read any local .vimrc file set mousehide " Don't show mouse cursor in gui set ic " Ignore case set noic " Don't ignore case set nocompatible " Use vim settings instead of vi set magic " Use magic symbols in regexps set shiftround " Round to multiples of shiftwidth " Save settings: use ':h viminfo' for details set viminfo=f1,'50,\"1000,:0,h,%,nd:\\don\\0rc\\viminfo " Long-lived macros highlight Normal guibg=Black guifg=White syntax on " Allow backspacing over autoindented lines set backspace=indent,start set history=50 " Keep 50 lines of command line history set hlsearch " Highlight the search pattern set incsearch " Show incremental search matches " Backup options. The intention of these settings is to always leave " a backup copy around on the disk. Periodically clean out the directory. set backup set backupdir=c:\\tmp\\tmp\\vimbup set writebackup set sh=c:/cygwin/bin/bash.exe set matchpairs=(:),{:},[:],<:> set joinspaces " Use 2 spaces after '.' when joining a line set wildmenu " Show enhanced command line completion set wildignore=.bak,~,.o,.obj,.swp,.TR2,.tds set wildmode=longest,list,full set wildchar= set showmatch set matchtime=3 " The swap file directory set dir=c:\\tmp\\tmp\\vimbup set define=^\\s*#\\s*define set include=^\\s*#\\s*include set lazyredraw " Don't redraw while executing macros " Display status line with ruler and ASCII value of character under cursor "set statusline=%M%r%f%=%l,%c\ \ %P\ [%L\ lines]\ 0x%B set statusline=%M\ %l,%c\ \ %r\ \ %P\ \ \ \ %L\ lines\ \ \ \ %t set display=lastline set tw=0 set tw=70 set showcmd set shortmess=aoOstTWAI set smartcase set noequalalways set restorescreen set visualbell set expandtab set autoindent set winminheight=0 set nowrapscan set tabstop=4 set shiftwidth=4 set nowrap set ruler set ttyfast set report=5 set undolevels=500 set cpoptions="aAcdFs" set modeline set modelines=10 set nostartofline set winaltkeys=no " Allow any mappings with ALT key. set comments=://,b:#,:%,n:>,fb:-,fb:* "set formatoptions=tcq " How comments & text get formatted set formatoptions=troncaqw " How comments & text get formatted set formatoptions=rncq "======================================================================== " Mappings noremap ( :set list! " Toggle showing tabs and end of line noremap ) :set nu! " Toggle numbering lines noremap & :set wrap! " Toggle wrapping noremap E :e . " Edit the current directory noremap U :redo " Redo the last undo noremap V  " Go backwards a page noremap v  " Go forward a page "noremap W  " Go back to previous position noremap _ :set nolist:set nonu " Turn off list and numbering noremap u :undo " Multiple level undo " Peform a substitution between marks a and b noremap zg :'a,'bs; noremap zk 10+ " Enlarge current window by 10 lines noremap zK _ " Maximize current window noremap zl  " Switch to next window noremap zL W " Switch to next window noremap zp :split " Split the current window noremap zP :Project " Open the project window noremap z= = " Make all windows equal height noremap zm _ " Maximize and switch to next window " Move between splits with ctrl-J and ctrl-K and maximize the current " window. set winminwidth=0 map j_ map k_ " This also does the same for vertical splits nmap h nmap l " Launch my help stuff in a new window noremap zh :split d:/bin/bat/help_system/index.hld " Use to turn on "change tracking" for this file. How: copy the current " buffer to a temp file, diffsplit it into a new window, and hide the split " window. noremap zT :!cp % c:/tmp/%.vimtemp:diffsplit c:/tmp/%.vimtempzl:hide:set foldcolumn=0zA0 noremap zY :diffupdate " Format the current paragraph to tw columns noremap zu gqap " Format current paragraph noremap z4 :set tw=40 noremap z5 :set tw=50 noremap z6 :set tw=60 noremap z7 :set tw=65 noremap z8 :set tw=70 noremap z9 :set tw=79 noremap z0 :set tw=0 noremap zZ :qall " Exit when lots of windows are open " Dealing with tags noremap z. " Go to the indicated tag and center it noremap z :tj " Go to the indicated tag or show list of multiple tags noremap T  " Return from a tag jump noremap } " Open a tags window for item under cursor noremap z " Close the tags window noremap lh " Avoids calling help noremap z :set hls! " Toggle search highlighting " Toggle syntax highlighting on and off noremap :if has("syntax_items")syntax offelsesyntax onendif " Specific syntax highlighting noremap :so $VIM/syntax/sh.vim noremap :so $VIM/syntax/make.vim noremap :so $VIM/syntax/cpp.vim noremap :so $VIM/syntax/python.vim "======================================================================== " Abbreviations iab xhdr /******************************************************************************************************************************************************/ iab xsep /**************************************************************************/ iab xhy ---------------------------------------------------------------------- iab xruler ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---- iab href "======================================================================== " gvim stuff set guifont=lucida_console:h8:b "======================================================================== " Autocommands (executed when the specified file type is read) autocmd BufRead *.c set cindent autocmd BufRead *.h set cindent autocmd BufRead *.cpp set cindent " Allows use of the q key to quit when reading a vim help file autocmd BufRead */vim62/doc/*.txt map q :q!:unmap q autocmd BufRead *.man map q :q!:unmap q " Exit when q is pressed autocmd BufRead *.hld so $VIM/syntax/donhelp.vim autocmd BufRead *.hld map q :q!:unmap q " Exit when q is pressed autocmd BufRead *.hld map  " Tag forward autocmd BufRead *.hld map t  " Tag backwards autocmd BufRead *.hld map  " Tag backwards " My special syntax files autocmd BufRead *.mp so d:/don/.vim/syntax/mp.vim autocmd BufRead *.txt so d:/don/.vim/syntax/txt.vim "======================================================================== " Folding set foldcolumn=0 " Set to >= 2 to see the fold info " Set folding colors hi Folded ctermfg=darkgray ctermbg=black guibg=black guifg=darkgray hi FoldColumn ctermfg=yellow ctermbg=black guibg=black guifg=darkgray " Folding is used a lot, so connect it to the spacebar noremap :call OutlineToggle()z. " This came from a tip from the vim website. It toggles folding. function! OutlineToggle() let OldLine = line(".") let OldCol = virtcol(".") if (! exists ("b:outline_mode")) let b:outline_mode = 0 let b:OldMarker = &foldmarker endif if (b:outline_mode == 0) let b:outline_mode = 1 set foldmethod=marker set foldmarker={,} silent! exec "%s/{<>/}>>/" else let b:outline_mode = 0 set foldmethod=marker let &foldmarker=b:OldMarker silent! exec "%s/{<>/}>>/" endif execute "normal! ".OldLine."G" execute "normal! ".OldCol."|" unlet OldLine unlet OldCol execute "normal! zv" endfunction ":command! -nargs=0 OUTLINE call OutlineToggle() "======================================================================== command! -nargs=0 Todo :split\ p:/todo " Set colors colorscheme donp " Handy function/map to do tab completion in insert mode function! InsertTabWrapper() let col = col('.') - 1 if !col || getline('.')[col - 1] !~ '\k' return "\" else return "\" endif endfunction "inoremap =InsertTabWrapper() "======================================================================== " From ':h CursorHold' "set updatetime=4000 "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 != "" " if there is one ":ptag" to it " " " 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 " let v:errmsg = "" " exe "silent! ptag " . w " if v:errmsg =~ "tag not found" " return " endif " " 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 " vim: tw=0