[svlug] Text Editor

Marc MERLIN marc_merlin at magic.metawire.com
Thu Nov 5 10:44:08 PST 1998


On 5 Nov 1998 03:37:00 -0800, Larry M. Augustin <lma at varesearch.com> wrote:
>let them draw you to the dark side.  If your editor isn't programmable
>enough to run simple programs like the Towers of Hanoi and Tetris, how

Pfff.
ESC:so $VIM/macros/hanoi/hanoi.mac
g

It goes from:
---
01234567
0
0
 
  
T0123456n
T0123456$
/
---

to:

---
0
01234567
0


T0123456n
T0123456$
/
---
Note that  this isn't vim specific,  it also works with  straight vi. My vim
also  comes with  life  (you know,  like  the sun  screensaver)  and a  maze
program.


As for Tetris, no one (that I know of) as ever bothered, but it's easily
doable.
ESC:help perl
---
Here are some things you can try:

  :perl $a=1
  :perldo $_=reverse($_);1
  :perl VIM::Msg("hello")
  :perl $line = $curbuf->Get(42)


                                                        *perl-overview*
Here is an overview of the functions that are available to Perl:

  :perl VIM::Msg("Text")               # displays a message
  :perl VIM::Msg("Error", "ErrorMsg")  # displays an error message
  :perl VIM::Msg("remark", "Comment")  # displays a highlighted message
  :perl VIM::SetOption("ai")           # sets a vim option
  :perl ($v, $success) = VIM::Eval('&path') # $v=option 'path', $success=1
  :perl ($v, $success) = VIM::Eval('&xyz')  # $v='' and $success=0 (no option)
  :perl $v = VIM::Eval(expand("<cfile>"))   # expand <cfile>
  :perl $curwin->SetHeight(10)         # sets the window height
  :perl @pos = $curwin->Cursor()       # returns (row, col) array
  :perl @pos = (10, 10)
  :perl $curwin->Cursor(@pos)          # sets cursor to @pos
  :perl $curwin->Cursor(10,10)         # sets cursor to row 10 col 10
  :perl $curbuf->Name()                # returns buffer name
  :perl $curbuf->Count()               # returns the number of lines
  :perl $l = $curbuf->Get(10)          # returns line 10
  :perl @l = $curbuf->Get(1 .. 5)      # returns lines 1 through 5
  :perl $curbuf->Delete(10)            # deletes line 10
  :perl $curbuf->Delete(10, 20)        # delete lines 10 through 20
  :perl $curbuf->Append(10, "Line")    # appends a line
  :perl $curbuf->Append(10, "Line1", "Line2", "Line3") # appends 3 lines
  :perl @l = ("L1", "L2", "L3")
  :perl $curbuf->Append(10, @l)        # appends L1, L2 and L3
  :perl $curbuf->Set(10, "Line")       # replaces line 10
  :perl $curbuf->Set(10, "Line1", "Line2")     # replaces lines 10 and 11
  :perl $curbuf->Set(10, @l)           # replaces 3 lines

---

Let's just say vim people spend their time on more constructive things than
rewriting a mail program not as good as mutt inside their editor :-)

Marc
-- 
"Microsoft is to software what McDonalds is to gourmet cooking"
 
Home page: http://marc.merlins.org/ (friendly to non IE browsers)
Finger marc at merlins.org for PGP key and other contact information

--
echo "unsubscribe svlug" | mail majordomo at svlug.org
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ to unsubscribe



More information about the svlug mailing list