URL: http://www.math.fu-berlin.de/~guckes/vim/macros/ URL: http://www.vim.org/macros/ (mirror) Created: Mon Feb 22 18:00:00 CET 1999 Last update: Tue Feb 23 12:00:00 CET 1999
TODO: Add macros from the VIM FAQ and from posts on comp.editors.
Description: This script "mirrors" (reverses) the contents of the text between (the line marked with) 'a' and the current line. The script is sourced with a map to "\fm". Depending on the kind of map for "\fm" the order of the lines will remain or be reversed, too.
Instructions: Let your shell export VIMSCRIPT which points to the directory where you keep your scripts for Vim, eg "export VIMSCRIPT=/Vol/Pub/share/vim/syntax".
Define this map:
"mirror.vim script : "mirror images" the current line
" Uses my mz "y
normal ^my$mz
"
if col("'y") < col("'z")
" note: the first time, mz is at $, and when the character
" at 'a is deleted, mz travels backwards with $
normal `yl"yd`y`z"yphmzl"yd`z`y"yP`ylmy
endif
"
while col("'y") < col("'z")
" note: normally, marks will remain in the same column,
" and will *not* travel with the marked character
" during deletions
normal `yl"yd`y`zhmz"yphmzl"yd`z`y"yP`ylmy
endwhile
Go to some line, ma.
Move to end-of-block.
These lines will now be mirror-imaged.
Example:
map \fr o<Esc>mz'aO<Esc>ma:'a+1,'z-1g/^/m 'a<CR>'add'zdd