Vic <[EMAIL PROTECTED]> on 08/16/2000 05:24:36 PM

Please respond to [EMAIL PROTECTED]
                                                              
                                                              
                                                              
 To:      [EMAIL PROTECTED]                           
                                                              
 cc:      (bcc: Lonny Selinger/SaskPower)                     
                                                              
                                                              
                                                              
 Subject: Re: [expert] Vi/Vim - The editor from HELL! How do  
          I set the default editor soI can TRASH IT?          
                                                              








Then when one is finished, press the escape key or Esc key,
this brings it into command mode which one can then
type an uppercase Q to telll vi to get ready to quit.

This will then get it ready to save to a file,
so then type w mytext.txt and it will
save whatever you typed in that file into a file
named mytext.txt

Then if you are done type an x and it should
write the info you typed to the file and exit.

another way you can do writes (especialy if multiple occurances of an open
file exist) is to force write
:w! (same idea as doing a write quit to exit) :wq!


Now, if you want to edit an existing file,
then bring up your terminal window or
at your text terminal type vi filename.txt
and vi should just pop up with that file in it,
and all you have to do to start making changes is
to press the i key and use the arrow keys to
get down where you want to be and start typeing,
then to save your changes, press the Esc key (also called escape key)
and then type an upppercase Q and then just type a w and
it should save, then type x to quit vi.

That is about all I know about vi, I
just messed around with it even though
I had no use for it at the time, I sometimes
use it just to see what it does, pure curiosity.

As for why the hell it was written the way it
was I have no idea, but it would be helpful if

--> vi was written to be a very fast powerful editor with quick easy
commands and key sequences for doing editing on huge files etc. Some of the
features I tend to take advantage of are things like being able to read
system information into a file or executing commands from the command line
with standard out being written into the current document. For example: in
vi if you wanted to *read in* a directory listing etc while in comand mode
you can type :!r ls -l /some/directory  the bang "!" passes the argument to
the shell, "r" says to read this information into the current file, and
then the command you want to execute (this is great for *spur of the
moment* logging or if you use vi/vim as your email editor and are trying to
get help on something and would like to show the person you are contacting
your screen output from a command you ran, you can put it right in your
email/file in real time (no cutting and pasting)

Another great thing is global search nad replace (substitution). For
Example: if for some reason a file you have, has been written and you would
like to change every occurance of the word "Workstation" because it should
have been "Server", you can change every instance with one line ... even if
the file is a GiG long :-)  most of these commands are culminatiopns of awk
and sed as well as simple shell commands. To do the change I mentioned you
would type something like:
:g/Workstation/s//Server/g
g=apply this globally to whatever is between the / /'s (/Workstation/)
s/=substitute
g=globally throughout the file (not just the first occurance in each line)

One more feature I will bring up (becasue you're probably sick of reading
;-) is the fact that you can actually put litteral escape sequences in
files OR remove them. If anyone has copied over a file from a Winblows
machine you may have noticed a whack of newline characters or <ENTER>
sequences. These usually show up in the form of ^M  this is NOT <SHIFT>6
captial M ... it is a litteral representation of <ENTER>. In vi/vim
pressing <CTRL>v while in Insert mode allows you to enter these or using
the substitution, remove them. Example: pressing <CTRL>v and then hitting
<ENTER> will give you the ^M ...if you have a whole bunch of them in a file
you can remove tem all byt typing...

:g/^M/s///g

g=same as above
^M=<CTRL>v <ENTER>
s/=substitute for whatever is between the second / /'s (this begin nothing
.. they are ampty)  ;-)

I could go on but if you really want to more of the features you can use or
even build into vi/vim yourself check the web...its FULL of great info on
creating vimrc files as well as explaining all the help tools built into
vim. It seems to me that anything worth learning takes lots of time to
appreciate ... I hated vi for a long time and stayed with things like pico
..... now I dont even use graphical editors for doing any real work to text
files etc and I love vi/vim.  I guess vi and vim are more for people who
appreciate the command line and shells which is all even Linux used to be.
As







Reply via email to