" ================================================================== " File: $HOME/.vimrc.forall (sourced by ~USER/.vimrc) " Latest change: Fri Dec 04 02:00:00 CET 2015 " Purpose: Setup file for the editor Vim (Vi IMproved) " Availability: This file is available as " ----K " 67.7K " Size: about 67.7KB in size and about 1,900 lines. " only about 300 lines are not commented - " the rest is documentation with hints. " (as you can see with 'grep -cv '^"' filename') " So don't be afraid to read through this file. " It should be quite easy to understand. " Questions? Send them to me! " Author: Sven Guckes setup-vimrc.forall(at)guckes.net " http://www.guckes.net/ " =================================================================== " Installation of this setup file: " To use this setup file, copy it to " this filename on these systems: " ~/.vimrc Unix and OS/2 " s:.vimrc Amiga " $VIM\_vimrc MS-DOS and Win32 " for more info see ":help vimrc"! " =================================================================== " version check: " The first line of this setup file contains the information " "version xxx" which allows VIM to check whether the setup file " fits the syntax that it understands. " Versions of VIM other than of version 5 then will give a warning " as they do not understand this setup file command - a feature: " Give a warning so the user knows that there is something odd " about the setup file. " =================================================================== " =================================================================== " Structure of this file: " Lines starting with an inverted comma (") are comments. " Some mappings are commented out. Remove the comment to enable them. " " There are three kinds of things which are defined in this file: " Mapping ("map"), settings ("set"), and abbreviations ("ab"). " Settings affect the behaviour of commands. " Mappings maps a key sequence to a command. " Abbreviations define words which are replaced " right *after* they are typed in. " " =================================================================== " Note on mappings - "angle notation" (see ":help <>"): " VIM allows you to define mappings with special characters " with a notation that uses non-special characters: " The notation encloses decriptive words in angle brackets (<>). " The characters you will most often are: " for control-m " for control-v which quotes the following character " for the escape character. " All control characters have been replaced to use the angle notation " so you should be able to read this file without problems. " (Well, sometimes I leave some tabs [control-i] in the file. ;-) " =================================================================== " External programs: " Some mappings make use of external programs. " The following you should find/have on every UNIX system: " cut, date; awk, egrep, grep, ispell, perl, sed, sort. " =================================================================== " Let people know that they are using this setup file: " echo "Welcome to Sven's setup file for all users!" " =================================================================== " Online Help - jump to help positions with "\\": " On some keyboards you will have some trouble with C-], " the command to jump to the current help tag. " The following mapping allows to use "\\", too: map \\ map map ß " the tab isn't used as a command in command mode, is it? " =================================================================== " The command ":version" does not show the current value of " VIMRUNTIME - dang! So I need a fast way to display that value: nmap VV :echo $VIMRUNTIME " =================================================================== " =================================================================== " HTML - HTML - HTML - HTML - HTML - HTML - HTML - HTML " =================================================================== " This has become quite big - so I moved it out to another file: " http://www.guckes.net/vim/source/html.vim [1998-02-27,2003-10-10] " The "expand" is necessary to evaluate "~guckes". let FILE=expand("~guckes/.vim/after/html.vim") if filereadable(FILE) exe "source " FILE endif " =================================================================== " =================================================================== " SETTING OPTIONS " =================================================================== " There are many options for Vim: " VIM-5.4 [1999-07-26] 218 options. " VIM-5.7 [2000-06-24] 219 options. " VIM-6.1 [2002-03-24] 310 options. " VIM-6.2 [2003-06-01] 322 options. " VIM-6.4 [2006-01-12] 324 options. (:opt -> 275 options) " VIM-7.4 [2013-11-07] 377 options. (:opt -> 302 options) " check the source with the following command: " grep '{".*P_' src/option.c | wc -l " =================================================================== " " autoindent, paste, textwidth: " I keep changing these values - just as the case may be. " Now, if functions keys actually worked on all keyboards " then I'd probably defines a toggle for each of them... " " autoindent: "off" as I usually do not write code. set noautoindent " " autowrite: Automatically save modifications to files " when you use critical (rxternal) commands. set autowrite " " backup: backups are for wimps ;-) set nobackup " " backspace: '2' allows backspacing" over " indentation, end-of-line, and start-of-line. " see also "help bs". set backspace=2 " " background: Are we using a "light" or "dark" background? " set background=dark " " compatible: Let Vim behave like Vi? Hell, no! set nocompatible " " comments default: sr:/*,mb:*,el:*/,://,b:#,:%,:XCOMM,n:>,fb:- " set comments=b:#,:%,fb:-,n:>,n:) set comments=b:#,:%,n:>,n:) " " cpoptions you should get to know - source of many FAQs! ;-) " cpoptions: "compatible options" to match Vi behaviour " set cpoptions="aABceFs" "default! " FAQ: Do NOT include the flag '<' if you WANT angle notation! " " dictionary: english words first " set dictionary=/usr/dict/words,/local/lib/german.words,~/.vim/dictionary set dictionary=~/.vim/dictionary " expand words from dictionaries, too: set complete+=k " /usr/share/dict/american-english " /usr/share/dict/german " /usr/share/dict/ngerman " /usr/share/dict/words " Source for dictionaries (in unix-format): " ftp://ftp.fu-berlin.de/misc/dictionaries/unix-format/ " However, these are quite old. Is there a better source? " " digraph: allows entering special characters " by a combination of two characters -> :help digraph " 2007-04-27: on an utf8 terminal it causes errors " of no end though because whenever you make a typo " and you erase with CTRL-H then you almost alyway " get a digraph of some sort. :-/ set nodigraph " " errorbells: damn this beep! ;-) " "vi has two modes - one in which it beeps " and another inw hich it doesn't." set noerrorbells " " esckeys: allow usage of cursor keys within insert mode " You will find this useful when working, eg, on SunOS. set esckeys " " In case you want this for SunOS only: " if system('uname')=='SunOS' " set ek " endif " " expandtab: Expand Tabs? Rather not. " See 'listchars' to make Tabs visible! set noexpandtab " " formatoptions: Options for the "text format" command ("gq") " I need all those options (but 'o')! set formatoptions=cqrt " " helpheight: zero disables this. set helpheight=0 " " helpfile: path+filename of the main helpfile, ie "help.txt" " set helpfile=c:\\vim-4.6\\docs\\help.txt " set helpfile=c:/vim-4.6/docs/help.txt " On Windows, I put the Vim helpfiles " into the directory C:\VIM-version, eg C:\VIM-62 " " hidden: Allow "hidden" buffers. A must-have! set hidden " " highlighting modes for special groups " highlight=8b,db,es,is,mb,Mn,nu,rs,sr,tb,vr,ws " set highlight=8r,db,es,is,mb,Mr,nu,rs,sr,tb,vr,ws " two changes: ^ ^ " all highlighting - all OFF: " set " highlight=8-,@-,d-,e-,i-,m-,M-,n-,r-,s-,S-,c-,t-,v-,w-,W-,f-,F-,A-,C-,D-,T-,>- " highlight=8b,@?,db,es,is,mb,Mn,nu,rs,sr,tb,vr,ws " " highlight default: " 8:SpecialKey, " @:NonText, " d:Directory, " e:ErrorMsg, " i:IncSearch, " l:Search, " m:MoreMsg, " M:ModeMsg, " n:LineNr, " r:Question, " s:StatusLine, " S:StatusLineNC, " c:VertSplit, " t:Title, " v:Visual, " V:VisualNOS, " w:WarningMsg, " W:WildMenu, " f:Folded, " F:FoldColumn, " A:DiffAdd, " C:DiffChange, " D:DiffDelete, " T:DiffText, " >:SignColumn " " hlsearch : highlight search - show the current search pattern " This is a nice feature sometimes - but it sure can get in the " way sometimes when you edit. set nohlsearch " " icon: i do not need no steekeen icon title string. set noicon " " set iconstring file of icon (icons? on a terminal? pff!) " set iconstring " " ignorecase: ignore the case in search patterns? NO! set noignorecase " " insertmode: " FAQ: Q: How can I quit insertmode when using this option? " A: The option "insertmode" was not meant for "start Vim in " insert mode" only; the idea is to *stay* in insert mode. " Anyway, you can use the command |i_CTRL-O| to issue commands. set noinsertmode " " " iskeyword: " iskeyword=@,48-57,_,192-255 (default) " Add the dash ('-'), the dot ('.'), and the '@' as "letters" to "words". " This makes it possible to expand email and html addresses, " eg foobar@vim.org and http://www.vim.org/ set iskeyword=@,48-57,_,192-255,-,.,:,/,@-@ map ,isk :set isk=@,48-57,_,192-255,-,.,:,/,@-@ " " joinspaces: " insert two spaces after a period with every joining of lines. " I like this as it makes reading texts easier (for me, at least). set joinspaces " " keywordprg: Program to use for the "K" command. " set keywordprg=man\ -s " " laststatus: show status line? Yes, always! " laststatus: Even for only one buffer. set laststatus=2 " " [VIM5]lazyredraw: do not update screen while executing macros set lazyredraw " " 'list' + 'listchars': Great new feature of vim-5.3! " This tells Vim which characters to show for expanded TABs, " trailing whitespace, and end-of-lines. VERY useful!! " Standard settings: " set list " set listchars=tab:>-,trail:·,eol:$ " " However: The '$' at the end of lines is a bit too much, though. " And I quite like the character that shows a dot in the middle: " set listchars=tab:>·,trail:· " " Some people might prefer a double right angle (>>) " to show the start of expanded tabs, though: " set listchars=tab:»·,trail:· " " However, this all breaks up when viewing high-bit characters " through some brain-dead telnet program (there are many). " Sometimes a change of the font does the trick. Try it! " " magic: Use 'magic' patterns (extended regular expressions) " in search patterns? Certainly! (I just *love* "\s\+"!) set magic " " 2006-05-09: include angle brackets, too! set matchpairs=(:),{:},[:],<:> " " modeline: Allow the last line to be a modeline - useful when " the last line in sig gives the preferred textwidth for replies. set modeline set modelines=1 " " number: no line numbering. line numbers take away eight " characters - and that's too much. four digits usually suffice. set nonumber " " nrformats: no "alpha", no "octal" -> " only de/increase numbers of decimal format. set nrformats= " " path: The list of directories to search when you specify " a file with an edit command. " Note: "~/.P" is a symlink to my dir with www pages " "$VIM/syntax" is where the syntax files are. " set path=.,,~/.P/vim,~/.P/vim/runtime/syntax,~/.P/vim/source,$VIM/syntax/ " set path=.,,~/.P/vim,~/.P/mutt/,~/.P/elm,~/.P/slrn/,~/.P/nn " " pastetoggle set pastetoggle= " also turn on/off 'paste' from insert mode and show its current value: "imap :set paste!:set paste?a " note that the mapping for F5 is defined for command mode - " and that the pastetoggle is used within insert mode! " " report: show a report when N lines were changed. " report=0 thus means "show all changes"! set report=0 " " ruler: show cursor position? Yep! set ruler " " runtimepath: list of dirs to search for runtime files " runtimepath is for Vim-6 only! " set runtimepath=~/.vim,~/.vim/after " set runtimepath+=~guckes/.vim " set runtimepath+=~guckes/share/vim/runtime/ " set runtimepath+=~guckes/share/vim/ " set runtimepath+=~guckes/.P/Vim/syntax " set runtimepath+=~guckes/share/vim/vim60ao/ " had to set this now that Vim won't use "helpfiles" " to look for runtime files any more. " " Setting the "shell" is always tricky - especially when you are " trying to use the same vimrc on different operating systems. " DOS: if has("dos16") || has("dos32") let shell='command.com' endif " " Windows: if has("win32") let shell='cmd.exe' endif " " UNIX: if has("unix") " let &shell="bash" " let &shell="ksh" " let &shell="tcsh" let &shell="zsh\ -l" " zsh rules! :-) " see http://www.zsh.org endif " " shiftwidth: Number of spaces to use for each " insertion of (auto)indent. " set shiftwidth=8 set shiftwidth=2 " " shortmess: Kind of messages to show. Abbreviate them all! " New since vim-5.0v: flag 'I' to suppress "intro message". set shortmess=atI " " showcmd: Show current uncompleted command? Absolutely! set showcmd " " showmatch: Show the matching bracket for the last ')'? set showmatch " " showmode: Show the current mode? YEEEEEEEEESSSSSSSSSSS! set showmode " " suffixes: Ignore filename with any of these suffixes " when using the ":edit" command. " Most of these are files created by LaTeX. set suffixes=.aux,.bak,.dvi,.gz,.idx,.log,.ps,.swp,.tar " " startofline: no: do not jump to first character with page " commands, ie keep the cursor in the current column. set nostartofline " " splitbelow: Create new window below current one. set splitbelow " " statusline: customize contents of the windows' status line. " I prefer it this way: " Show the current buffer number and filename with info on " modification, read-only, and whether it is a help buffer " (show only when applied). " set statusline=[%n]\ %f\ %(\ %M%R%H)%) " " Move the rest to the right side, eg a copyright text: " set statusline=[%n]\ %f\ %(\ %M%R%H)%)%=(c)\ Sven\ Guckes " " Show the value of the current character in ASCII and Hex: " set statusline=[%n]\ %f\ %(\ %M%R%H)%)\=ASCII=%b\ HEX=%B " " Show the current position with line+column+virtual_column: " set statusline=[%n]\ %f\ %(\ %M%R%H)%)\=Pos=<%l\,%c%V>\ %P " Adding color through UserN groups: " set statusline=%1*[%02n]%*\ %2*%F%*\ %(\ %M%R%H)%)%=%3*Pos=<%l,%c%V>%* " User1: color for buffer number " hi User1 ctermfg=red ctermbg=white " User2: color for filename " hi User2 ctermfg=green ctermbg=white " hi User2 ctermfg=green ctermbg=black " User3: color for position " hi User3 ctermfg=blue ctermbg=white " " 2005-04-12: more fun with the statusline. " this shows the current time in the statusline: " set statusline=%{strftime('%c')} " the time will be update with every redraw of the statusline. " so usually just right after you *did* something. " just move the cursor to have the time updated. " " tabstop set tabstop=8 " " tagbsearch: use "binary search" on tags file? no. " why? because i use my own structure - " and this breaks the binary structure. set notagbsearch " " tags: file for "tags" - search words set tags=~/.vim/mytags " " 1999-05-03: I have to set the "term" explicitly " because the standard setups are broken. " set term=builtin_pcansi " set term=xterm " " Set the colors for vim on "xterm" " if &term=="xterm" " set t_Co=8 " set t_AB=[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm " set t_AF=[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm " endif " " textwidth set textwidth=79 " " title: set notitle " " ttyfast: are we using a fast terminal? " this setting depends on where I use Vim... " set nottyfast " " ttybuiltin: set nottybuiltin " " ttyscroll: turn off scrolling -> faster! set ttyscroll=0 " " ttytype: " set ttytype=rxvt " " viminfo: What info to store from an editing session " in the viminfo file; can be used at next session. set viminfo=\"200,%,'200,/100,:100,@100,f1,h,n~/.vim/viminfo " " visualbell: set visualbell " " t_vb: terminal's visual bell - turned off to make Vim quiet! " Please use this as to not annoy cow-orkers in the same room. " Thankyou! :-) set t_vb= " " whichwrap: " Allow jump commands for left/right motion to wrap to previous/next " line when cursor is on first/last character in the line: set whichwrap=<,>,h,l,[,] " " wildchar the char used for "expansion" on the command line " default value is "" but I prefer the tab key: set wildchar= " " wrapmargin: set wrapmargin=1 " " writebackup: " i dont need backup files in my directories. " actually, i save my file right when i stop typing. " back in the olden days i lost some huge texts " because i was going for hours without saving. " well, i have learnt my lesson! ":w" is in my fingers now.. set nowritebackup " " =================================================================== " ABbreviations " =================================================================== " 1998-07-01: Moved the abbreviations *before* the mappings as " some of the abbreviations get used with some mappings. " " Let's start of with some standard strings " like the alphabet and the digits: " " Yalpha : The lower letter alphabet. iab Yalpha abcdefghijklmnopqrstuvwxyz cab Yalpha abcdefghijklmnopqrstuvwxyz " " YALPHA : The upper letter alphabet. iab YALPHA ABCDEFGHIJKLMNOPQRSTUVWXYZ " " Ydigit: The ten digits. iab Ydigit 1234567890 " Yhex: The sixteen digits of a hexadecimal system. iab Yhex 1234567890ABCDEF " " Yruler: A "ruler" - nice for counting the length of words. " 80 digits there - just perfect for a standard terminal! iab Yruler 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 " " Abbreviations for some important numbers: iab Npi 3.1415926535897932384626433832795028841972 iab Neuler 2.7182818284590452353602874713526624977573 " " =================================================================== " Abbreviations - Header Lines for Email and News " =================================================================== " Define regexpr for headers to use with mappings " as it makes reading the mappings much easier: " cab HADDR From\\|Cc\\|To cab HEMAIL ^\(From\\|Cc\\|To\\|Date\\|Subject\\|Message-ID\\|Message-Id\\|X-\) cab HNEWS ^\(From\\|Cc\\|To\\|Date\\|Subject\\|Message-ID\\|X-\\|Newsgroups\) " " =================================================================== " Abbreviations - General Editing - Inserting Dates and Times " =================================================================== " " First, some command to add date stamps (with and without time). " I use these manually after a substantial change to a webpage. " [These abbreviations are used with the mapping for ",L".] " iab Ydate =strftime("%y%m%d") " Example: 1997-10-27 " iab Ytime =strftime("%H:%M") " Example: 14:28 " " man strftime: %T time as %H:%M:%S " iab YDT =strftime("%y%m%d %T") " Example: 1997-10-27 12:00:00 " " man strftime: %X locale's appropriate time representation iab YDT =strftime("%y%m%d %X") " Example: 2000-03-20 20:20:20 " " current date with dashes iab YDate =strftime("%Y-%m-%d") " current date with dashes iab dddd =strftime("%F") " Example: 2002-04-06 " current date with spaces iab dddds =strftime("%Y %m %d") " Example: 2016 01 15 " iab YDATE =strftime("%a %b %d %T %Z %Y") " Example: Tue Dec 16 12:07:00 CET 1997 " " 2020-10-23 Date: string in email headers: iab YDDDD =strftime("%a, %d %b %Y %T %z (%Z)") " example: "Fri, 23 Oct 2020 17:23:42 +0200 (CEST)" " see also: date +'%a, %d %b %Y %T %z' " see also: man strftime " " " On Windows the functions "strftime" seems to have a different " format. Therefore the following may be necessary: [1998-07-30] " if !has("unix") " iab YDATE =strftime("%c %a") " else " iab YDATE =strftime("%D %T %a") " endif " " 2000-03-06: These two lines at the start of a Perl script " will start the first Perl in your Shell's $PATH. iab Yperlhead eval 'exec perl -w -S $0 ${1+"$@"}'if 0; " " " =================================================================== " MAPpings " =================================================================== " Caveat: Mapping must be "prefix free", ie no mapping must be the " prefix of any other mapping. Example: "map ,abc foo" and " "map ,abcd bar" will give you the error message "Ambigous mapping". " " The backslash ('\') is the only(?) unmapped key, so this is the best " key to start mappings with as this does not take away a command key. " However, the backslash is never in the same position with keyboards. " Eg on German keyboards it is AltGr-sz - don't ask. " Anyway, I have decided to start mappings with the comma as this " character is always on the same position on almost all keyboards " and I hardly have a need for that command. " " The following maps get rid of some basic problems: " " When the backspace key sends a "delete" character " then you simply map the "delete" to a "backspace" (CTRL-H): " map " " With Vim-4 the format command was just 'Q' and " I am too used to it. So I need this back! nnoremap Q gq vnoremap Q gq " " 1998-05-27 I often reformat a paragraph to fit some textwidth - " and I use the following mapping to adjust it to the " current position of the cursor: map , :set textwidth==col(".") " map #tw :set textwidth==col(".") " " 1998-12-10 Whenever I paste some text into VIM I have to " toggle from "nopaste" to "paste" and back again: " map :set paste!:set paste? " map [14~ :set paste!:set paste? " --> new option for this: 'pastetoggle' " " "tal" is the "trailer alignment" filter program " Hopefully it will ship with Vim one day. " vmap #t !tal " vmap #t !tal -p 0 " " Disable the command 'K' (keyword lookup) by mapping it " to an "empty command". (thanks, Lawrence! :-): " map K : " map K : " More elegant: (Hi Aziz! :-) map K " " Disable the suspend for ^Z. " I use Vim under "screen" where a suspend would lose the " connection to the " terminal - which is what I want to avoid. " map :shell " " 2004-12-25 " i'd rather use CTRL-Z for scrolling like CTRL-Y does map " " Make CTRL-^ rebound to the *column* in the previous file noremap `" " " Make "gf" rebound to last cursor position (line *and* column) " noremap gf gf`" noremap gf :e " " When I let Vim write the current buffer I frequently mistype the " command ":w" as ":W" - so I have to remap it to correct this typo: " nmap :W :w " TODO: Use the following (after some testing): " command -nargs=? -bang W w " " Are you used to the Unix commands "alias" and "which"? " I sometimes use these to look up my abbreviations and mappings. " So I need them available on the command line: " map :alias map " map :which map " " The command {number}CTRL-G show the current buffer number, too. " This is yet another feature that vi does not have. " As I always want to see the buffer number I map it to CTRL-G. " Please note that here we need to prevent a loop in the mapping by " using the comamnd "noremap"! noremap 2 " " 2000-10-10 Do the Color Test! map ,CT :sp $VIMRUNTIME/syntax/colortest.vim:so % " 2000-03-29 View the file which defines the "filetypes": map ,F :view $VIMRUNTIME/filetype.vim " " 1998-03-11 Sourcing syntax files:: map ,SO :source $VIMRUNTIME/syntax/ " " 1998-07-06,2000-03-10 View a syntax file: map ,V :view $VIMRUNTIME/syntax/ " " 2014-10-07, 2016-05-10 source the 2html.vim " map ,2 :so $VIMRUNTIME/syntax/2html.vim map ,2 :TOhtml " " 2000-08-01 Hilite Test - show all current highlight groups " see ":help hitest.vim" map ,HI :so $VIMRUNTIME/syntax/hitest.vim " " 1999-06-14 Quick insertion of an empty line: " nmap o " I find this convenient - but as I am also used to proceed to " next line by pressing CR this often gives me new empty lines " when I really do not need them. :-( " " =================================================================== " Customizing the command line " =================================================================== " Valid names for keys are: " " " Many shells allow editing in "Emacs Style". " Although I love Vi, I am quite used to this kind of editing now. " So here it is - command line editing commands in emacs style: cnoremap cnoremap " cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap b cnoremap cnoremap f cnoremap cnoremap " Note: More info about this is in the helptexts: :help emacs-keys " " Additional codes for that "English" keyboard at the Xterminal cnoremap [D cnoremap [C " " =================================================================== " VIM - Editing and updating the vimrc: " As I often make changes to this file I use these commands " to start editing it and also update it: if has("unix") let vimrc='~/.vimrc' else " ie: if has("dos16") || has("dos32") || has("win32") let vimrc='$VIM\_vimrc' endif nn ,u :source =vimrc nn ,v :edit =vimrc " ,v = vimrc editing (edit this file) " map ,v :e ~/.vimrc " ,u = "update" by reading this file " map ,u :source ~/.vimrc " =================================================================== " " General Editing " " Define "del" char to be the same backspace (saves a LOT of trouble!) " As the angle notation cannot be use with the LeftHandSide " with mappings you must type this in *literally*! " map 127 "cmap 127 " the same for Linux Debian which uses imap [3~ " " ;rcm = remove "control-m"s - for those mails sent from DOS: cmap ;rcm %s///g " " Make whitespace visible: " Sws = show whitespace nmap ,Sws :%s/ /_/g vmap ,Sws :%s/ /_/g " " Sometimes you just want to *see* that trailing whitespace: " Stws = show trailing whitespace nmap ,Stws :%s/ *$/_/g vmap ,Stws :%s/ *$/_/g " " =================================================================== " General Editing - Umlauts for Krauts " =================================================================== " problem: some programs change non-ASCII to ASCII " by stripping off the the highest bit. " this will turn umlauts to characters like D and V: " Ä -> D Ö -> V Ü -> \ ä -> d ö -> v ü -> | " " so here are some easy ways to transcribe umlauts " or represent them in HTML: " " Turning umlauts into ascii (for German keyboards) " imap ä ae " imap ö oe " imap ü ue " imap ß ss " " %s/\Ä/Ä/gc " %s/\Ö/Ö/gc " %s/\Ü/Ü/gc " %s/\ä/ä/gc " %s/\ö/ö/gc " %s/\ü/ü/gc " " Substituting transcribed umlauts to real umlauts: " cmap ,ae %s/ae/ä/gc cmap ,Ae %s/Ae/Ä/gc cmap ,oe %s/oe/ö/gc cmap ,Oe %s/Oe/Ö/gc cmap ,ue %s/ue/ü/gc cmap ,Ue %s/Ue/Ü/gc cmap ,ss %s/ss/ß/gc " " Substituting umlauts to their transcription: " cmap ;ae %s/ä/ae/g " cmap ;Ae %s/Ä/Ae/g " cmap ;oe %s/ö/oe/g " cmap ;Oe %s/Ö/Oe/g " cmap ;ue %s/ü/ue/g " cmap ;Ue %s/Ü/Ue/g " cmap ;ss %s/ß/ss/g " no questions required -> can be done with a sed script " " 2013-11-05 " sed script to turn all paragraphs into one line: " sed -r '/^$/!{:a;N;/\n$/b;s|\n| |;ba}' filename " " From: George Georgalis " To: sed-users@yahoogroups.com " Subject: Re: change paragraphs to long lines " Date: Tue, 5 Nov 2013 21:12:54 -0800 " .. with help from Thierry Blanc and Davide Brini " " =================================================================== " Inserting Dates and Times / Updating Date+Time Stamps " =================================================================== " ,L = "Last update" - replace old time stamp with a new one " preserving whitespace and using internal "strftime" command: " requires the abbreviation "YDATE" map ,L 1G/Latest.change:\s*/e+1CYDATE " map ,,L 1G/Last update:\s*/e+1CYDATE " Example: " before: "Last update: Thu Apr 6 12:07:00 CET 1967" " after: "Last update: Tue Dec 16 12:07:00 CET 1997" " " I used to read in the output from the external command "date" " but this is a little slow and does not work on all systems: " map ,L 1G/Last update: */e+1D:r!datekJ " " 2016-04-07 " updating the previous Date: line: map ,D ?Date: ?e CYDATE " =================================================================== " General Editing - link to program "screen" " =================================================================== " " ,Et = edit temporary file of "screen" program map ,Et :e /tmp/screen-exchange " as a user of Unix systems you *must* have this program! " see also: http://www.guckes.net/screen/ " " Email/News - Editing replies/followups " " Part 1 - prepare for editing " " Part 2 - getting rid of empty (quoted) lines and space runs. " " Delete trailing whitespace: nmap :%s/\s\+$// vmap :s/\s\+$// nmap ,9 :%s/\s\+$// vmap ,9 :s/\s\+$// " " ,cel = "clear empty lines" " - delete the *contents* of all lines which contain only whitespace. " note: this does not delete lines! " map ,cel :g/^[ ]*$/d map ,cel :%s/^\s\+$// " " ,del = "delete 'empty' lines" " - delete all lines which contain only whitespace " note: this does *not* delete empty lines! map ,del :g/^\s\+$/d " 2020-11-18 " delete lines which are quoted map ,dd :g/^[> ]\+$/d " " ,cqel = "clear quoted empty lines" " Clears (makes empty) all lines which start with '>' " and any amount of following spaces. " nmap ,cqel :%s/^[> ]*$// " vmap ,cqel :s/^[> ]*$// " nmap ,cqel :%s/^[> ]\+$// " vmap ,cqel :s/^[> ]\+$// nmap ,cqel :%s/^[>]\+$// vmap ,cqel :s/^[> ]\+$// " NOTE: If the meta sequence "\s" " The following does not work because "\s" is not a character " and thus cannot be part of a "character set". " map ,cqel :%s/^[>\s]\+$// " " Some people have strange habits within their writing. " But if you cannot educate them - rewrite their text! ;-) " " Jason "triple-dots" King elephant@onaustralia.com.au " does uses ".." or "..." rather than the usual punctuation " (comma, semicolon, colon, full stop). So... " " Turning dot runs with following spaces into an end-of-sentence, " ie dot-space-space: vmap ,dot :s/\.\+ \+/. /g " " candida keeps forgetting to insert a space after commas - " example: "a sentence with a comma,and not space after it!" " so i have to keep inserting these spaces " myself before i can reformat her text: map :g/^> /s/,\([^ ]\)/, \1/g " " Gary Kline (kline@tera.tera.com) indents his " own text in replies with TAB or spaces. " Here's how to get rid of these indentation: " vmap ,gary :s/^>[ ]\+\([^>]\)/> \1/ " " ,ksr = "kill space runs" " substitutes runs of two or more space to a single space: " nmap ,ksr :%s/ */ /g " vmap ,ksr :s/ */ /g " nmap ,ksr :%s/ \+/ /g " vmap ,ksr :s/ \+/ /g nmap vip:s/ \+/ /g vmap :s/ \+/ /g nmap ,0 vip:s/ \+/ /g vmap ,0 :s/ \+/ /g " " Why can't the removal of space runs be " an option of "text formatting"? *hrmpf* " " ,Sel = "squeeze empty lines" " Convert blocks of empty lines (not even whitespace included) " into *one* empty line (within current visual): map ,Sel :g/^$/,/./-j " " ,Sbl = "squeeze blank lines" " Convert all blocks of blank lines (containing whitespace only) " into *one* empty line (within current visual): " map ,Sbl :g/^\s*$/,/[^ ]/-j " map ,Sbl :g/^\s*$/,/[^ \t]/-j map ,Sbl :g/^\s*$/,/\S/-j " " =================================================================== " AUTOCOMMANDS: " Editing of email replies and Usenet followups - using autocommands " =================================================================== " " First step: Remove ALL auto-commands. This avoids having the " autocommands twice when the vimrc file is sourced again. autocmd! " au BufRead,BufNewFile .followup,postpone/* so ~/.vim/slrn_followup " " Add/change some filename patterns to filetypes: " let myfiletypefile = "~/.vim/myfiletypes" " " And this goes into "~/.vim/myfiletypes": " augroup filetype " au BufRead,BufNewFile postpone/* set filetype=mail " augroup END " " Apply my syntax file on files with extension "sdg": au BufNewFile,BufRead *.sdg set ft=sveng " " Apply the muttrc coloring to my mutt setup files: au BufNewFile,BufRead .mutt.* set ft=muttrc " " SLRN: Apply mail.vim to postponed messages: au BufNewFile,BufRead */postpone/*,muttng-* set ft=mail " " Set some options for "messages" (FileType "mail"): " au FileType mail set autoindent expandtab tabstop=4 textwidth=70 " the following uses ethe short option names: au FileType mail set ai et ts=4 tw=70 " " Some more autocommand examples which set the values for " "autoindent", "expandtab", "shiftwidth", "tabstop", and "textwidth": " using the "FileType" event: " au FileType c set ai et sw=4 ts=4 " au FileType perl set ai et sw=4 ts=4 " au FileType html set ai sw=2 ts=2 " au FileType java set ai sw=4 ts=4 " au BufEnter */drafts/* set tw=72 " " Try to use the mapping ",D" when doing a followup. " autocmd BufNewFile ~/.followup ,D| " " Setting "X-Editor": " Let Vim identify itself in the message header " when editing emails with Mutt and Slrn: " au FileType mail let @"="X-Editor: Vim-".version." http://www.vim.org/\n"|exe 'norm 1G}""P' " " Generation of a "Message-ID" header line (according to ISO8061): " " Let Vim add a Message-ID to your posts with Slrn: " " Add a Message-ID to posts with Slrn: " au BufNewFile,BufRead ~/.article let @"="Message-ID: \n"|exe 'norm 1G}""P' " Example: Message-ID: <20000406T120700@guckes.net> " Problem: The date and time are hard to read. " It's easier with a few delimiters: " Add a Message-ID to posts with Slrn (with delimiters): " au BufNewFile,BufRead ~/.article,~/.followup let @"="Message-ID: <".strftime("%Y-%m-%dT%H-%M-%S")."@guckes.net>\n"|exe 'norm 1G}""P' " Example: Message-ID: <2000-04-06T12-07-00@guckes.net> " " 2012-05-27: Message-ID generation on windows " (broken across four lines) - by Uwe Premer: " au BufNewFile,BufRead " c:/slrn/article.txt,c:/slrn/followup.txt " let " ."="Message-ID: " <".strftime("%d-%m-%Y_%HUhr%M.%S").".nntp.DOMAINNAME>\n"| " exe "'norm 1G}""P' " " news.fu-berlin.de rejects Message-IDs with colons in it: " Example: Message-ID: <2000-04-06T12:07:00@guckes.net> " " " Part 3 - Change Quoting Level " " ,dp = de-quote current inner paragraph " map ,dp {jma}kmb:'a,'bs/^> // map ,dp vip:s/^> // vmap ,dp :s/^> // " " ,qp = quote current paragraph " jump to first inner line, mark with 'a'; " jump to last inner line, mark with 'b'; " then do the quoting as a substitution " on the line range "'a,'b": " map ,qp {jma}kmb:'a,'bs/^/> / " vim-5 now has selection of "inner" and "all" " of current text object - mapping commented! " " ,qp = quote current paragraph (old version) " jump to first inner line, Visual, " jump to last inner line, " then do the quoting as a substitution: " map ,qp {jV}k:s/^/> / " " ,qp = quote current inner paragraph (works since vim-5.0q) " select inner paragraph " then do the quoting as a substitution: map ,qp vip:s/^/> / " " ,qp = quote current paragraph " just do the quoting as a substitution: vmap ,qp :s/^/> / " " ## = comment current inner paragraph with '#': nmap ## vip:s/^/#/ " ## = comment current text selection with '#': vmap ## :s/^/#/ " " 2000-10-06: Commenting selected lines in C style: " vmap ## :s#^#// #''>o*/gv " " Example of result: " /* " // foo " // bar " /* " " Changing quote style to *the* true quote prefix string "> ": " " Fix Supercite aka PowerQuote (Hi, Andi! :-): " before ,kpq: > Sven> text " after ,kpq: > > text " ,kpq kill power quote vmap ,kpq :s/^> *[a-zA-Z]*>/> >/ " " Fix various other quote characters: " ,fq "fix quoting" vmap ,fq :s/^> \([-":}\|][ ]\)/> > / " " Fix the quoting of "Microsoft Internet E-Mail": " The guilty mailer identifies like this: " X-Mailer: Microsoft Internet E-Mail/MAPI - 8.0.0.4211 " " And this is how it quotes - with a pseudo header: " " -----Ursprungliche Nachricht----- " Von: NAME [SMTP:ADDRESS] " Gesendet am: Donnerstag, 6. April 2000 12:07 " An: NAME " Cc: NAME " Betreff: foobar " " And here's how I "fix" this quoting: " (it makes use of the mappings ",dp" and ",qp"): map #fix1 /^> -----.*-----$Oj,dpdapVG,qp " " 2001-06-13 " X-Mailer: Internet Mail Service (5.5.2650.21) " Oh, boy, I *hate* this mailer. This " one certainly sends *crappy* mails. " Eg it adds "[NAME]__" to each new text. " This should remove it from the mail body: map #fix2 :/^$/,$s/\t\[.*\]\s\+// " " Part 4 - Weed Headers of quoted mail/post " " These mappings make use of the abbreviation that define a list of " Email headers (HEMAIL) and News headers (HNEWS): nmap ,we vip:v#HEMAIL#d vmap ,we :v#HEMAIL#d nmap ,wp vip:v#HNEWS#d vmap ,wp :v#HNEWS#d " " ,ri = "Read in" basic lines from the email header " Useful when replying to an email: " nmap ,ri :r!readmsg\|egrep "^From:\|^Subject:\|^Date:\|^To: \|^Cc:" " NOTE: "readmsg" ships with the mailer ELM. " " " Part 5 - Reformatting Text " " NOTE: The following mapping require formatoptions to include 'r' " and "comments" to include "n:>" (ie "nested" comments with '>'). " " Formatting the current paragraph according to " the current 'textwidth' with ^J (control-j): " imap gqap " too dangerous for my editing ;-) nmap gqap vmap gq " 2020-11-19 map , :set tw=65gqip " " Here is a variation of this command. It inserts the character " CTRL-Z at the current position to enable to rebound to the " previous position within the text. [Hello, Y. K. Puckett!] " map igqip?x " imap gqip?xi " " Some people prefer to use extrernal formatting utilities " such as "fmt" or "par": " nmap !}fmt " vmap !fmt " " " ,b = break line in commented text (to be used on a space) " nmap ,b dwi> nmap ,b r " ,j = join line in commented text " (can be used anywhere on the line) " nmap ,j Jxx nmap ,j Vjgq " " ,B = break line at current position *and* join the next line " nmap ,B i>Jxx nmap ,B rVjgq " " ,,, break current line at current column, " inserting ellipsis and "filling space": " nmap ,,, ,,1,,2 " nmap ,,1 a...X...FXrlmaky$o" " nmap ,,2 :s/./ /g3X0"yy$dd`a"yP " " " =================================================================== " Edit your reply! (Or else!) " =================================================================== " " Part 6 - Inserting Special or Standard Text " Part 6a - The header " Add adresses for To: and Cc: lines " " ,ca = check alias (reads in expansion of alias name) " map ,ca :r!elmalias -f "\%v (\%n)" " ,Ca = check alias (reads in expansion of alias name) " map ,Ca :r!elmalias -f "\%n <\%v>" " " ,cc = "copy notice" " Insert a Cc line so that person will receive a "courtesy copy"; " this tells the addressee that text is a copy of a public article. " This assumes that there is exactly one empty line after the first " paragraph and the first line of the second paragraph contains the " return address with a trailing colon (which is later removed). map ,cc 1G}jyykPICc: $x " map ,cc ma1G}jy/ writes'aoCc: $p " " ,mlu = make letter urgent (by giving the "Priority: urgent") map ,mlu 1G}OPriority: urgent " " Fixing the From: line " " ,cS = change Sven's address. " map 1G/^From: /e+1CSven Guckes " Used when replying as the "guy from vim". " " Adjusting my Reply-To line [2000-10-10] " " Reply-To: usenet-reply@guckes.net " " ,cr = change Reply-TO line " map ,cr 1G/^Reply-To: guckes-usenet/e-5ct@ " " Fixing the Subject line " " Pet peeve: Unmeaningful Subject lines. Change them! " ,cs = change Subject: line " map ,cs 1G/^Subject: yypIX-Old--W map ,cs 1G/^Subject: yypIX-Old-kW " This command keeps the old Subject line in "X-Old-Subject:" - " so the recipient can still search for it and " you keep a copy for editing. " " 2000-11-15: " ,CS = Change Subject: line map ,CS 1G/^Subject: :s/Re:/was:/Wi($)0Wi " This changes the "Re:" to "was:", puts everything into parentheses " and then sets the cursor before the opening bracket for insertion " of a new Subject line (which hopefully matches the contents better). " Subject: Re: something " Subject: X(was: something) " " " ,re : Condense multiple "Re:_" to just one "Re:": map ,re 1G/^Sub:s/\(Re: \)\+/Re: / " " ,Re : Change "Re: Re[n]" to "Re[n+1]" in Subject lines: map ,Re 1G/^Subject: :s/Re: Re\[\([0-9]\+\)\]/Re[\1]/ " " Put parentheses around "visual text" " Used when commenting out an old subject. " Example: " Subject: help " Subject: vim - using autoindent (Re: help) " " ,) and ,( : vmap ,( v``>a) vmap ,) v``>a) " " Part 6 - Inserting Special or Standard Text " Part 6a - Start of text - saying "hello". " " ,hi = "Hi!" (indicates first reply) map ,hi 1G}oHi! " " ,ha = "helloagain" (indicates reply to reply) map ,ha 1G}oHello, again! " " ;HA = "Hallo, !" (German equivalent of "hi!" for replies) " map ;HA G/Quoting /e+1ye1G}oHallo, !Po " map ;HA G/^\* /e+1ye1G}oHallo, !Po map ;; G/^\* /e+1ye1G}oHallo, "! map ;h G/^\* /e+1ye1G}ohello, "! map ;s G/^\* /e+1ye1G}oServus, "! " Austrian version " " ,He = "Hello, !" " map ,He G/Quoting /e+1ye1G}oHallo, !Po map ,He G/^\* /e+1ye1G}oHello, !Po " " Part 6 - Inserting Special or Standard Text " Part 6b - End of text - dealing with "signatures". " " remove signatures " " ,kqs = kill quoted sig (to remove those damn sigs for replies) " goto end-of-buffer, search-backwards for a quoted sigdashes " line, ie "^> -- $", and delete unto end-of-paragraph: map ,kqs G?^> -- $d} " map ,kqs G?^> *-- $dG " ,kqs = kill quoted sig unto start of own signature: " map ,kqs G?^> *-- $d/^-- $/ " " =================================== " Adding quotes and signatures easily " =================================== " " QUOTES: http://www.guckes.net/quotes/collection " let QUOTES=expand("~/.P/quotes/collection") " " Decide which quote file to use: " if filereadable("~/.P/quotes/collection") " let QUOTES=expand("~/.P/quotes/collection") " else " use a copy in the homedir: " let QUOTES=expand("~/.quotes") " endif " " ,aq = "add quote" " Reads in a quote from my favourite quotations: " nmap ,aq :exe ":r!agrep -d '^-- $' ".QUOTES " nmap ,aq :r!agrep -d "^-- $" '' ~/.P/quotes/collection nmap ,aq :r!awk // RS='\n-- \n' ~/.P/quotes/collection " " SIGNATURES: http://www.guckes.net/sig/SIGS " " let SIGS=expand("~/.P/sig/SIGS") " if !filereadable(SIGS) " use a copy in the homedir: " let SIGS=expand("~/.signatures") " endif " " ,s = "sign" - " Read in signature file (requires manual completion): " nmap ,s :r!agrep -d "^-- $" ~/.P/sig/SIGS " nmap ,s :exe ":r!agrep -d '^-- $' ".SIGS " nmap ,s :exe ":r!agrep -d '^-- $' '' ".SIGS " nmap ,s :r!agrep -d "^-- $" '' ~/.P/sig/SIGS " 2015-10-30 " nmap ,s :r!awk // RS='-- ' ~/.P/sig/SIGS nmap ,s :r!awk // RS='-- ' ~/.P/sig/SIGS " 2014-08-08, 2015-12-04 " including some phone numbers " nmap ,t :r!agrep -h -i -d '^$' '' ~/.phone/*.txt " nmap ,t :r!agrep -h -i -d '^$' '' ~/.phone/*.txt nmap ,t :r!awk // RS='\n\n' ~/.phone/*.txt " " SEE ALSO: " Sven's page on sigs: http://www.guckes.net/sig/ " Sven's page on agrep: http://www.guckes.net/agrep/ " " ,at = "add text" - " read in text file (requires manual completion): nmap ,at :r ~/.P/txt/ " " MUTT: Auto-kill signatures for replies " map ,kqs G?^> *-- $dG " autocmd BufNewFile,BufRead .followup,.letter,mutt*,nn.*,snd.* :normal ,kqs " " At the end of editing your reply you should check your spelling " with the spelling checker "ispell". " These mappings are from Lawrence Clapp lclapp@iname.com: " spellcheck the document -- skip quoted text " nmap :w ! grep -v '^>' \| spell " vmap :w ! grep -v '^>' \| spell " At home under Linux it looks something more like this: " nmap :w ! grep -v '^>' \| ispell -??? " " Tell the recipient that I was replying to an old email of his: " ab SvenRE Sven [finally taking the time to reply to old emails] " " Toggles: [todo] " " toggle autoindent " toggle hlsearch " cycle textwidth between values 60, 70, 75, 80 " " =================================================================== " LaTeX - LaTeX - LaTeX - LaTeX - LaTeX - LaTeX - LaTeX " =================================================================== " let FILE="/home/robinson/emailer/guckes/.vim/after/latex.vim" " if filereadable(FILE) " let RESULT="file readable" " exe "source " . FILE " else " let RESULT="file not readable" " endif " " =================================================================== " PGP - encryption and decryption " =================================================================== " " encrypt " map ;e :%!/bin/sh -c 'pgp -feast 2>/dev/tty' " decrypt " map ;d :/^-----BEG/,/^-----END/!/bin/sh -c 'pgp -f 2>/dev/tty' " sign " map ;s :,$! /bin/sh -c 'pgp -fast +clear 2>/dev/tty' " map ;v :,/^-----END/w !pgp -m " " PGP - original mappings " " encrypt and sign (useful for mailing to someone else) "csh: map #1 :,$! /bin/sh -c 'pgp -feast 2>/dev/tty^V|^V|sleep 4' " sh: map #1 :,$! pgp -feast 2>/dev/tty^V|^V|sleep 4 " " sign (useful for mailing to someone else) "csh: map #2 :,$! /bin/sh -c 'pgp -fast +clear 2>/dev/tty' " sh: map #2 :,$! pgp -fast +clear 2>/dev/tty " " decrypt "csh: map #3 :/^-----BEG/,/^-----END/!\ " /bin/sh -c 'pgp -f 2>/dev/tty^V|^V|sleep 4' " sh: map #3 :/^-----BEG/,/^-----END/!\ " pgp -f 2>/dev/tty^V|^V|sleep 4 " " view (pages output, like more) "csh: map #4 :,/^-----END/w !pgp -m " sh: map #4 :,/^-----END/w !pgp -m " " encrypt alone (useful for encrypting for oneself) "csh: map #5 :,$! /bin/sh -c 'pgp -feat 2>/dev/tty^V|^V|sleep 4' " sh: map #5 :,$! pgp -feat 2>/dev/tty^V|^V|sleep 4 " " Elijah http://www.mathlab.sunysb.edu/~elijah/pgppub.html says : " The significant feature is that stderr is redirected independently " of stdout, and it is redirected to /dev/tty which is a synonym for " the current terminal on Unix. I don't know why the ||sleep 4 " stuff is there, but it is harmless so I left it. Since csh is such " junk, special rules are used if you are using it (tcsh, too). " ksh and bash should use the sh form. zsh, et al: consult your " manual. The # format is used to map function keys. If your " terminal does not support the requested function key, use a " literal #. Not all of the clones correctly support this. " " =================================================================== " Useful stuff. At least these are nice examples. :-) " =================================================================== " " ,t = "transpose" - aXb -> bXa " This exchanges the characters 'a' and 'b' " which are next to the current position on 'X': " map ,t XpxphXp " map ,t xphXpxp " " #b = "browse" - send selected URL to Netscape "vmap #b y:!netscape -remote "openurl "" "vmap #b y:!netscape -remote 'openFile(")' \|\| netscape " & "vmap #b y:!netscape -remote 'openFile(%:p)' || netscape file:%:p & " " " make space move the cursor to the right - much better than a *beep* " nmap \ l " " ,E = execute line " map ,E 0/\$w"yy$:yr! " This command excutes a shell command from the current line and " reads in its output into the buffer. It assumes that the command " starts with the fist word after the first '$' (the shell prompt " of /bin/sh). Try ",E" on that line, ie place the cursor on it " and then press ",E": " $ ls -la " Note: The command line commands have been remapped to tcsh style!! " " ROT13 rot13 " ,dr = decode/encode rot13 text " vmap ,dr :!tr A-Za-z N-ZA-Mn-za-m " Use this with an external "rot13" script: " " ,13 - rot13 the visual text " vmap ,13 :!rot13 " NOTE: Vim now has ROT13 built-in - see ":help g?". " see also: http://www.guckes.net/rot13/ " " Give the URL under the cursor to Netscape " map ,net yA:!netscape -remote "openurl "" " " " =================================================================== " Mapping of special keys - arrow keys and function keys. " =================================================================== " Buffer commands (split,move,delete) - " this makes a little more easy to deal with buffers. " (works for Linux PCs in room 030) " map :split " map :bp " map :bn " map :bd " " Buffer commands (split,move,delete) - " for Mac keyboard (Performa 5200, US keyboard) " " map [19~ :split " map [20~ :bp " map [23~ :bn " map [31~ :bd " " Obvious mappings " " map " map " " =================================================================== " FAQ: "Emacs editing" " Q: How can I stay in insert mode and move around like within Emacs? " A: Get the following file and source it like it is done here: " let FILE="/home/robinson/emailer/guckes/.vim/after/emacs.vim" " if filereadable(FILE) " let RESULT="file readable" " exe "source " . FILE " else " let RESULT="file not readable" " endif " " Make the up and down movements move by "display/screen lines": " map j gj " map gj " map k gk " map gk " " Normal mode - tcsh style movements [1996-04-25] " " nmap 0 " nmap h " nmap x " nmap $ " nmap l " nmap b b " nmap f w " " DOS keyboard mapping for cursor keys " " map [A " map [B " map [C " map [D " imap [A " imap [B " imap [C " imap [D " " DOS keyboard " "insert" " map [1~ i " map [1~ " "home" " map [2~ ^ " map [2~ 0 " map [2~ " "pgup" " map [3~ " map [3~ " "delete" " map [4~ x " map [4~ " "end" " map [5~ $ " map [5~ " "pgdn" " map [6~ " map [6~ " " Keyboard mapping for cursor keys " [works for SUNs in Solarium (room 030) - 1997-08-15] " map OA map OB map OC map OD imap OA imap OB imap OC imap OD " " Keyboard mapping for cursor keys " [works for XTerminals - 1997-08-18] map [A map [B map [C map [D cmap [A cmap [B cmap [C cmap [D imap [A imap [B imap [C imap [D " " " 2005-02-15: FCC ID: FSQ4VY FK-2000 PLUS map [11~ map [12~ map [13~ map [14~ map [15~ " yes - "16" does not exist map [17~ map [18~ map [19~ map [20~ map [21~ " and the 22 des not exist, either map [23~ map [24~ " " 2006-05-07: map [224z map [225z map [226z map [227z map [228z map [229z map [230z map [231z map [232z map [233z " strange jump in numbers here: map [192z map [193z " 2000-08-10: " Keyboard mapping for numeric keypad: " imap ON ??? imap OM map OM imap OP map OP imap OQ / map OQ / imap OR * map OR * imap OS - map OS - " imap Ol + imap Om - imap On , imap Op 0 imap Oq 1 imap Or 2 imap Os 3 imap Ot 4 imap Ou 5 imap Ov 6 imap Ow 7 imap Ox 8 imap Oy 9 imap Oz 0 " " 2014-06-21 " strange sequences by my Acer Aspire on the console map [[A map [[B map [[C map [[D map [[E map [17~ map [18~ map [19~ map [20~ map [21~ map [23~ map [24~ " map [P [2~ INSERT " map [3~ DEL " =================================================================== " AutoCommands " =================================================================== " " Autocommands are the key to "syntax coloring". " There's one command in your vimrc that should " load/source the file $VIM/syntax/syntax.vim " which contains the definition for colors and " the autocommands that load other syntax files " when necessary, ie when the filename matches " a given pattern, eg "*.c" or *".html". " " just load the main syntax file when Vim was compiled with "+syntax" if has("syntax") " The following sources the main syntax file, " ie. "$VIM/syntax/syntax.vim", see ":help :syn-on": syntax on " Redefine the color for "Comment": " hi! Comment term=bold ctermfg=cyan ctermbg=black guifg=blue guibg=black " hi! Comment ctermfg=blue ctermbg=black guifg=blue guibg=black hi! Comment term=NONE cterm=NONE hi! Comment ctermfg=cyan ctermbg=black guifg=blue guibg=black " " The standard background color for the GUI Vim is "blue". " No, I don't know why. But many users want to change this " color to black so they can read the blue colored text. ;-) " Here's how: " hi normal ctermbg=black guibg=black " " Adjustments for editing messages: " the following file contains commands " which simply change a few colors: " au Syntax mail source ~guckes/.vim.mail.vim endif " " Definition of an alternative syntax file: " if has("syntax") " " Define the filename patterns for mail and news: " " MAILNEWSFILES... (missing, damn) " " Define the aucommand tow work on special files: " let aucommand = "au BufNewFile,BufRead ".MAILNEWSFILES " " execute the source command: " exe aucommand." source ~guckes/.vim/after/sven.vim" " " " endif " " " EXAMPLE: Restricting mappings to some files only: " An autocommand does the macthing on the filenames - " but abbreviations are not expanded within autocommands. " Workaround: Use "exe" for expansion: " let aucommand = "au BufNewFile,BufRead ".MAILNEWSFILES " exe aucommand." :map ,hi 1G}oHi!" " exe aucommand." :map ,ha 1G}oHello, again!" " exe aucommand." :map ,H G/Quoting /e+1ye1G}oHallo, !Po" " exe aucommand." :map ,re 1G}oRe!" " " Automatically place the cursor onto the first line of the mail body: " autocmd BufNewFile,BufRead MAILNEWSFILES :normal 1G}j " " Toggle syntax coloring on/off with "__": " nn __ mg:if has("syntax_items")syn clearelsesyn onen`g " Note: It works - but the screen flashes are quite annoying. :-/ " "map :if exists("syntax_on")\| syntax off\| else\| syntax on\| endif " " =================================================================== " EXAMPLES " =================================================================== " " 2002-01-21: Adding stars/brackets/inverted commas around selected text: " vmap #* `>a*`gv " vmap #( `>a)`gv vmap #* c**" vmap #( c()" " " Visualizing trailing whitespace: " :set hls " /\s\+$ " " Toggling a numerical variable between two values. " Example: Switch the textwidth (tw) between values "70" and "80": " map \1 :let &tw = 150 - &tw " " Capitalizing the previously typed word, " returning to the previous position: " imap CAP mzB~`za " " Uppercasing the previously typed word, " returning to the previous position: " imap CAP mzvBU`za " imap CAP mzBvaWU`za " " =================================================================== " TEMPORARY STUFF - TESTING THINGS " =================================================================== " " 2002-08-24: " extend current line unto the beginning " of the next word on the previous line: " imap :se ve=alljWki " imap :se ve=allkWji " " 2002-01-10: " reformat current paragraph up to current " column position as the textwidth: nmap ## :let tw2=&tw:let &tw=col(".")gqip:let &tw=tw2 " hint: use the mappings for F5 and F6 to narrow/widen the text. " " 2002-01-07: reversing a selected block of text " provided that either "rev" or "tac" " has been installed on your system: " vmap ## :!rev " vmap ## :!tac " " 2002-01-05: " reversing the lines within the current text selection: " vmap ## :g/^/m'< " vmap ## :g/^/co '<gvd " " 2000-12-01: Deleting text in normal mode " using the BackSpace and Delete keys: nmap X nmap x " " 2000-11-07 " Use "bc" to evaluate the arithmetic expression on the current line " with a precision of '6' digits after the comma. " It is assumed that the current line contains only the expression. " The rsult is read in after the current line. " map #BC ^y$:r!echo 'scale=6; "'\|bc " " 2000-10-10 " Add all numbers in the current visual selection. vmap ,add !awk '{total += $1 ; print} ; END {print total}' " " Example: " Remove comments from lines, select them with 'V' " then type ",add" and to execute "awk": " 123 " 456 " -789 " The result should be "210". " " 2004-02-23: " (de)indenting the current paragraph: map < map >ip vmap > " apparently F3 and F4 won't get recognized: map OR map OS " " Narrow/Widen current paragraph by " adjusting the current textwidth " and using internal formatting: map [[E :set tw-=2gqip map :set tw-=2gqip vmap :set tw-=2gvgqgv vmap [[E :set tw-=2gvgqgv vmap ( :set tw-=2gvgqgv map :set tw+=2gqip vmap :set tw+=2gvgqgv vmap ) :set tw+=2gvgqgv " " 2000-11-07: Use an explicit width for reformatting (here: 72): " map :let foo=&tw:se tw=72gqip:set tw=&foo " " screenshot from webpage shown with "links" " contains escape codes which need deleting. " vmap p :s#([0B]##g " " View a html document (or part of it) with lynx. You need " a system that supports the /def/fd/* file descriptors :-( " nmap ,ly :w !lynx -force_html /dev/fd/0 " vmap ,ly :w !lynx -force_html /dev/fd/0 " " Make Vim jump back one word in normal mode with , " when it produces the code "OD": " nmap OD b " " Some simple example of the "expand modifiers": " insert the current filename *with* path: iab YPATHFILE =expand("%:p") " insert the current filename *without* path: iab YFILE =expand("%:t:r") " insert the path of current file: iab YPATH =expand("%:h") iab YDIR =expand("%:p:h") " For more help see ":help filename-modifiers". " " Toggle highlight search and report the current value: " map #1 :set hls! " map #2 :echo "HLSearch: " . strpart("OffOn",3*&hlsearch,3) " map ## #1#2 " " Sorting current line containing a list of numbers " map ## :s/ //gvip!sort -n " " Replying to the mutt mailing list: " Remove header lines Cc: and Bcc: and insert [mutt] at the beginning " map ,MM 1G/^Cc:2dd}o[mutt] " " map ,U %s###gc " map ,F {jma}kmb:'a,'b!sed -e "s/^>//"|\ " sed -f ~/.P/elm/scripts/weedout.sed " map ,mb ebiEadw " " stripping netscape bookmarks and making them list items " vmap ,ns :.,$s/^ *
<\(A.*"\) ADD.*">\(.*\)$/
  • <\1>\2/ " " Jump to the last space before the 80th column. " map ,\| 80\|F " " extracting variable names from mutt's init.c " :%s/^.*"\([a-z0-9_]*\)".*$/\1/ " " \<> = change to <> notation by substituting ^M and ^[ " cab \<> s///gc:s///gc " " Changing the From_ line in pseudo mail folders to an appropriate " value - so you can read them with a mailer. " %s/^From /From guckes Thu Apr 6 12:07:00 1967/ iab FROM_ From guckes Thu Apr 6 12:07:00 1967 " " quote visual text with a border line around it " and with "[ TITLE ]" above it: vmap #t :s/^/\| /''>o `--------------- " " 2004-11-18 " sometimes i press shift-enter which " yields the "OM" sequence. " so i have to make it a proper CTRL-M: cmap OM " " Viewing PDF files in VIM " http://www.vim.org/tips/tip.php?tip_id=1356 autocmd BufReadPre *.pdf set ro autocmd BufReadPost *.pdf %!pdftotext -nopgbrk "%" - " =================================================================== " ASCII tables - you may need them some day. Save them to a file! " =================================================================== " " 2000-10-05: In need of an ASCII table? Perl is your friend: " perl -e 'while($i++<256) { print chr($i); }' " " ASCII Table - | octal value - name/char | " " |000 nul|001 soh|002 stx|003 etx|004 eot|005 enq|006 ack|007 bel| " |010 bs |011 ht |012 nl |013 vt |014 np |015 cr |016 so |017 si | " |020 dle|021 dc1|022 dc2|023 dc3|024 dc4|025 nak|026 syn|027 etb| " |030 can|031 em |032 sub|033 esc|034 fs |035 gs |036 rs |037 us | " |040 sp |041 ! |042 " |043 # |044 $ |045 % |046 & |047 ' | " |050 ( |051 ) |052 * |053 + |054 , |055 - |056 . |057 / | " |060 0 |061 1 |062 2 |063 3 |064 4 |065 5 |066 6 |067 7 | " |070 8 |071 9 |072 : |073 ; |074 < |075 = |076 > |077 ? | " |100 @ |101 A |102 B |103 C |104 D |105 E |106 F |107 G | " |110 H |111 I |112 J |113 K |114 L |115 M |116 N |117 O | " |120 P |121 Q |122 R |123 S |124 T |125 U |126 V |127 W | " |130 X |131 Y |132 Z |133 [ |134 \ |135 ] |136 ^ |137 _ | " |140 ` |141 a |142 b |143 c |144 d |145 e |146 f |147 g | " |150 h |151 i |152 j |153 k |154 l |155 m |156 n |157 o | " |160 p |161 q |162 r |163 s |164 t |165 u |166 v |167 w | " |170 x |171 y |172 z |173 { |174 | |175 } |176 ~ |177 del| " " =================================================================== " ASCII Table - | decimal value - name/char | " " |000 nul|001 soh|002 stx|003 etx|004 eot|005 enq|006 ack|007 bel| " |008 bs |009 ht |010 nl |011 vt |012 np |013 cr |014 so |015 si | " |016 dle|017 dc1|018 dc2|019 dc3|020 dc4|021 nak|022 syn|023 etb| " |024 can|025 em |026 sub|027 esc|028 fs |029 gs |030 rs |031 us | " |032 sp |033 ! |034 " |035 # |036 $ |037 % |038 & |039 ' | " |040 ( |041 ) |042 * |043 + |044 , |045 - |046 . |047 / | " |048 0 |049 1 |050 2 |051 3 |052 4 |053 5 |054 6 |055 7 | " |056 8 |057 9 |058 : |059 ; |060 < |061 = |062 > |063 ? | " |064 @ |065 A |066 B |067 C |068 D |069 E |070 F |071 G | " |072 H |073 I |074 J |075 K |076 L |077 M |078 N |079 O | " |080 P |081 Q |082 R |083 S |084 T |085 U |086 V |087 W | " |088 X |089 Y |090 Z |091 [ |092 \ |093 ] |094 ^ |095 _ | " |096 ` |097 a |098 b |099 c |100 d |101 e |102 f |103 g | " |104 h |105 i |106 j |107 k |108 l |109 m |110 n |111 o | " |112 p |113 q |114 r |115 s |116 t |117 u |118 v |119 w | " |120 x |121 y |122 z |123 { |124 | |125 } |126 ~ |127 del| " " =================================================================== " ASCII Table - | hex value - name/char | " " | 00 nul| 01 soh| 02 stx| 03 etx| 04 eot| 05 enq| 06 ack| 07 bel| " | 08 bs | 09 ht | 0a nl | 0b vt | 0c np | 0d cr | 0e so | 0f si | " | 10 dle| 11 dc1| 12 dc2| 13 dc3| 14 dc4| 15 nak| 16 syn| 17 etb| " | 18 can| 19 em | 1a sub| 1b esc| 1c fs | 1d gs | 1e rs | 1f us | " | 20 sp | 21 ! | 22 " | 23 # | 24 $ | 25 % | 26 & | 27 ' | " | 28 ( | 29 ) | 2a * | 2b + | 2c , | 2d - | 2e . | 2f / | " | 30 0 | 31 1 | 32 2 | 33 3 | 34 4 | 35 5 | 36 6 | 37 7 | " | 38 8 | 39 9 | 3a : | 3b ; | 3c < | 3d = | 3e > | 3f ? | " | 40 @ | 41 A | 42 B | 43 C | 44 D | 45 E | 46 F | 47 G | " | 48 H | 49 I | 4a J | 4b K | 4c L | 4d M | 4e N | 4f O | " | 50 P | 51 Q | 52 R | 53 S | 54 T | 55 U | 56 V | 57 W | " | 58 X | 59 Y | 5a Z | 5b [ | 5c \ | 5d ] | 5e ^ | 5f _ | " | 60 ` | 61 a | 62 b | 63 c | 64 d | 65 e | 66 f | 67 g | " | 68 h | 69 i | 6a j | 6b k | 6c l | 6d m | 6e n | 6f o | " | 70 p | 71 q | 72 r | 73 s | 74 t | 75 u | 76 v | 77 w | " | 78 x | 79 y | 7a z | 7b { | 7c | | 7d } | 7e ~ | 7f del| " =================================================================== " "[VIM6] foldmethod: " {Visual}zf => Operator to create a fold " zd => delete one fold at the cursor " za => toggle fold (open or close) " zc => close fold " zM => close all folds: set foldlevel to 0 (zero) " zo => open fold " zR => open all folds " zx => update folds: close manually opend folds " =================================================================== " Yet another example for an autocommand: [1998-06-16] au VimLeave * echo "Thanks for using Vim"version". --Sven Guckes@vim.org!" " =================================================================== " Last but not least... THPXRF " =================================================================== " The last line is allowed to be a "modeline" with my setup. " It gives vim commands for setting variable values that are " specific for editing this file. Used mostly for setting " the textwidth (tw) and the "shiftwidth" (sw). " Note that the colon within the value of "comments" needs to " be escaped with a backslash! (Thanks, Thomas!) " vim: set tw=70 et sw=4 comments=\:\": THPXRF: EOF