home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 March / PCWELT_3_2006.ISO / base / 05_common.mo / usr / share / elvis-2.2_0 / scripts / reverse.ex < prev    next >
Encoding:
Text File  |  2004-02-22  |  428 b   |  18 lines

  1. "This script defines a :reverse alias, which reverses the order of the
  2. "characters in a line.  By default it acts on the current line, but you
  3. "can also give it a range of lines to alter.  Leading whitespace is
  4. "unaffected.
  5. alias reverse {
  6.   "Reverse the characters in a line
  7.   !(.)% g /\S/ {
  8.     local t=true
  9.     s/^\s*/&<@>/
  10.     while t
  11.     do {
  12.       try s/\(<@>.*\)\(.\)/\2\1/
  13.       else set t=false
  14.     }
  15.     s/<@>$/
  16.   }
  17. }
  18.