[SATLUG] Question of the Week
Graichen, Othniel M Mr AMEDDCS
Othniel.Graichen at amedd.army.mil
Wed May 5 16:11:11 CDT 2004
Hello everyone!
And thanks out to those that responded.
Notepad and edit are text editors. Visual Studio and Emacs (since
you brought it up greg) are something more. I was looking forward
to a memory footprint discussion vs the amazingly efficient vi, but...
To say that Visual Studio is a text editor is to ignore that it is
a debugger, class browser, among others things which in Linux (this
is a LUG mailing list isn't it -- where are the OT police when you
need 'em?) are usually handled using separate tools. Speaking of
debuggers has anyone any experiences with DDD they would like to share?
In anycase we were discussing marks and hats off to indigot twilight
and matt valdez (apologies for lowercase) for their correct answers.
Let's review the answers and shoot me back a question if you don't
understand:
A1: In vi, marking a location in a text file to which you may want
to refer to later requires only two keystrokes (3 if you count shift)
They are lowercase m followed by a tag (any upper or lower case letter
will do fine).
I normally use lowercase because I never use more than 2 tags anyhow.
My convention is to use mx to mark the top of a section and my to mark
the bottom. I know that is limiting myself -- I could use 24 other
letters some probably more nmemonic but that's what I do.
A2: Matt Valdez answered this correctly, but it bears repeating. There
are two "move to tag" commands. You will want to use the gra've when
you are interested in the line and column which were marked, and you
will want to use the apostrophe when you are only interested in the line
which was marked. But these cursor movement commands are not just for
jumping around the text file. They can be combined with other commands
such as indent (shift-in or out), yank or delete. See next.
A3. In vi deleted text automatically goes into a clipboard called
the paste buffer. You may also copy text into such buffers. The
last 10 deletions are numbered numerically, and additional buffers
are available under manual control with single character (letter)
names. In anycase, to cut or copy text, return to the beginning
mark (using the two keystrokes 'x) then y'y will copy all the text
from the line containing the cursor to the line containing the y mark.
Under my breath as I am doing this I pronounce y'y as "y-go-y" (use
d-go-y if you want to cut). This copies (or deletes) both the top
and bottom lines in total. If you want to copy parts of lines you
will want to use the gra've instead -- you know.. the unshifted tilde?
I also pronounce this as "go" but I'm not confused.
A4. To paste its probably best if you move the cursor first, so here's
where the extra credit comes in. The keybinding for "Search again"
in vi is n, so you've probably searched for a unique variable identifier
recently (which is why tags/marks are so nice -- they don't interrupt
your find so you can repeat it again with 'n' Or you can use Page Up
or Down or something equally mundane to move the cursor to where you
want to paste and then press either p or P to perform the paste. Note
that p is different from P. P means before and p means after.
I use this capability all the time to cut/copy and paste source code
between text files.
Knowing how to use a proper text editor is key to being able to maintain
all the configuration files stored in Linux' registry -- the /etc directory.
"And yes vi is better than emacs."
Othniel Graichen
(Still campaigning for the support of the emacs users constituency).
:)
-----Original Message-----
From: satlug-bounces at satlug.org [mailto:satlug-bounces at satlug.org]On
Behalf Of Graichen, Othniel M Mr AMEDDCS
Sent: Wednesday, May 05, 2004 2:10 PM
To: satlug at satlug.org
Subject: [SATLUG] Question of the Week
Ok People:
Time for another Puzzler. If you don't know the answer, that's ok.
But stay tuned so as to listen to the answers given. You may find
another jewel that you can add to your bag of tools.
Here it is:
Using your favorite editor how do you:
1.) mark or uniquely identify locations within the file
2.) easily jump among these locations
3.) cut or copy text between marks to the clipboard
4.) paste the text to a new location
#4 is included for completeness. I am really only interested in
#1-3. The most advanced cursor movement features I've seen in an
MS windows text editors is page up/down or search again.
Obviously vi (vee eye) has all these features or I wouldn't be
asking. Extra credit: What is the search again keybinding in vi?
Have fun!
Othniel Graichen
_______________________________________________
Satlug mailing list
Satlug at satlug.org
http://alamo.satlug.org/mailman/listinfo/satlug
More information about the Satlug
mailing list