[comp.unix.questions] vi question

lwv@n8emr.UUCP (Larry W. Virden) (03/18/88)

When I go into vi with two edit files specified, I sometimes would like to be
able to edit just the first and say "Write out these changes and get out of
the program all together".  I tried writing a macro called Q which would do
a 
:wq!
and that didnt work.
I then tried to get it to do:
:wq!\n:q!
and that didnt seem to work.  Anyone have any more ideas?
Thanks!

-- 
Larry W. Virden	 75046,606 (CIS)
674 Falls Place, Reynoldsburg, OH 43068 (614) 864-8817
osu-cis!n8emr!lwv (UUCP) 	osu-cis!n8emr!lwv@PSUVAX1 (BITNET)
We haven't inherited the world from our parents, but borrowed it from our children.

brian@bucc2.UUCP (03/21/88)

> When I go into vi with two edit files specified, I sometimes would like to be
> able to edit just the first and say "Write out these changes and get out of
> the program all together".  I tried writing a macro called Q which would do
> a 
> :wq!
> and that didnt work.
> I then tried to get it to do:
> :wq!\n:q!
> and that didnt seem to work.  Anyone have any more ideas?
> Thanks!

Try:
map Q :wq!^VRETURN

  RETURN represents your enter key, be it marked newline, enter, return,
or whatever. ^V represents control-V.

  Note this could be a dangerous macro to have set up.

  Note also that if you re-map Q to do this, you can't use Q to do what
it normally does (go into ed-mode) without first unmapping Q.

...............................................................................

  When the going gets weird, the weird turn pro.

  Brian Michael Wendt       UUCP: {cepu,ihnp4,uiucdcs,noao}!bradley!brian
  Bradley University        ARPA: cepu!bradley!brian@seas.ucla.edu
  (309) 691-5175            ICBM: 40 40' N  89 34' W

rigoutso@ACF8.NYU.EDU (Isidore Rigoutsos) (06/14/89)

Hello everyone.
I have a vi question: whenever I execute a shell command from within vi,
(say 'fmt'), I get right before the point where the cursor was when I
executed the command a sequence of control characters, namely: ^[K
(Notice that this happens only on a SUN workstation and not on a VAX)
Where does this sequence come from and How can I get rid of it?
Thanks in advance,

isidore


-----------------------------------------------------------------------------
Isidore Rigoutsos 			   |INTERNET: rigoutso@acf8.nyu.edu
Robotics Lab., Computer Science Department,|BITNET: rigoutso%acf8@UCCVM.NYU.EDU
Courant Institute of Mathematical Sciences,|   or rigoutso%acf8@CUNYVM.CUNY.EDU
New York University, New York, NY 10012    |
-----------------------------------------------------------------------------

bobmon@iuvax.cs.indiana.edu (RAMontante) (06/14/89)

rigoutso@ACF8.NYU.EDU (Isidore Rigoutsos) <8906131928.AA24142@acf8.NYU.EDU> :
-
-I have a vi question: whenever I execute a shell command from within vi,
-(say 'fmt'), I get right before the point where the cursor was when I
-executed the command a sequence of control characters, namely: ^[K


Do you perhaps have a .cshrc file on the Sun machine which contains a
`tset...` command or something similar?  I've gotten spurious material
before from the new shell initializing with a .cshrc that generated output.
This is easy to see if you put an "echo message" line in the .cshrc file.
Always assuming that your shell is some variant of csh, of course...

mab@ulysses.att.com (Muhammad Basit) (06/15/90)

I have a simple vi question. How do I substitute a character with the
newline character in vi? I tried '\n', '\\n', the ascii code etc but
it doesn't seem to work. 

	I would very much appreciate a response from someone in
this regard. If this problem has already been discussed on the net
just send me an email.

Thank you all

MB

ronald@atcmp.nl (Ronald Pikkert) (06/15/90)

From article <13132@ulysses.att.com>, by mab@ulysses.att.com (Muhammad Basit):
> I have a simple vi question. How do I substitute a character with the
> newline character in vi? I tried '\n', '\\n', the ascii code etc but
> it doesn't seem to work. 
> 
> 	I would very much appreciate a response from someone in
> this regard. If this problem has already been discussed on the net
> just send me an email.
> 
> Thank you all
> 
> MB

David.Morgan@FtCollins.NCR.COM (David Morgan) (06/15/90)

try:
	<Cntl-V><Return>
--
*------*------*------*------*------*------*------*------*------*------*------*
David Morgan, CAD Software Development, NCR Microelectronics
2001 Danfield Court  		+-----------------------------------------
Ft. Collins, Colorado  80525	|   David.Morgan@FtCollins.NCR.com
(303)223-5100  Ext. 337		|   uunet!ncrlnk!ncr-mpd!bach!davem

tif@doorstop.austin.ibm.com (/32767) (06/16/90)

In article <13132@ulysses.att.com> mab@ulysses.att.com (Muhammad Basit) writes:
>I have a simple vi question. How do I substitute a character with the
>newline character in vi? I tried '\n', '\\n', the ascii code etc but
>it doesn't seem to work. 

Assuming that <r><ENTER> isn't what you want, type

	Qs/search-pattern/\<ENTER>/<ENTER>vi<ENTER>

This takes you to ex, which can handle this sort of thing.  "vi<ENTER>" puts
you back into vi.

Paul Chamberlain | I do NOT represent IBM	  tif@doorstop, sc30661@ausvm6
512/838-7008	 | ...!cs.utexas.edu!ibmaus!auschs!doorstop.austin.ibm.com!tif

cpcahil@virtech.uucp (Conor P. Cahill) (06/16/90)

In article <13132@ulysses.att.com> mab@ulysses.att.com (Muhammad Basit) writes:
>I have a simple vi question. How do I substitute a character with the
>newline character in vi? I tried '\n', '\\n', the ascii code etc but
>it doesn't seem to work. 

:1,$ s/c/^v^M/g     (^v is <ctrl-v> and ^M is <return>. You will only see ^M)



-- 
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.,
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170 

steinbac@hpl-opus.HP.COM (Gunter Steinbach) (06/16/90)

Use

:s/x/^M/

to replace x with a newline.  The "^M" gets typed in as Control-V Control-M.
Works for me on HP-UX 6.5.

	 Guenter Steinbach		gunter_steinbach@hplabs.hp.com

tchrist@convex.COM (Tom Christiansen) (06/16/90)

In article <13132@ulysses.att.com> mab@ulysses.att.com (Muhammad Basit) writes:
>I have a simple vi question. How do I substitute a character with the
>newline character in vi? I tried '\n', '\\n', the ascii code etc but
>it doesn't seem to work. 

From vi mode, something like:

:%s/foobar/foo^V^Mbar/g

Make sure you type control-V and control-M.  If you put this kind
of thing in a macro, you may find you need more control-V's.  

--tom
--

    Tom Christiansen                       {uunet,uiucdcs,sun}!convex!tchrist 
    Convex Computer Corporation                            tchrist@convex.COM
		 "EMACS belongs in <sys/errno.h>: Editor too big!"

mark@siva.UUCP (Mark Marsh) (06/17/90)

In article <13132@ulysses.att.com> mab@ulysses.att.com (Muhammad Basit) writes:
>I have a simple vi question. How do I substitute a character with the
>newline character in vi? I tried '\n', '\\n', the ascii code etc but
>it doesn't seem to work. 

When substituting a non-printing (ie control-character) into text in vi
the following sequence may be used:

s/<initial pattern>/[Ctrl-v]<non-printing character/

Example: 
To insert a newline character into the string "12345" after '3' then use:

s/12345/123[Crtl-v][Enter]45/

Note that in this example that text inside the square ([]) brackets 
indicate a keystroke
(ie [Enter] is pressing the Enter key, and [Ctrl-v] is holding down
the Control key, and while it is depressed, type the  v  key.)

-- 
mark@siva -or- {ames!pacbell!sactoh0}||{ucbvax!ucdavis!csusac!unify}!siva!mark
"But, I only did what you didn't tell me not to do!"             _Users Credo_

als@bohra.cpg.oz (Anthony Shipman) (06/28/90)

In article <2571@awdprime.UUCP>, tif@doorstop.austin.ibm.com (/32767) writes:
> In article <13132@ulysses.att.com> mab@ulysses.att.com (Muhammad Basit) writes:
> >I have a simple vi question. How do I substitute a character with the
> >newline character in vi? I tried '\n', '\\n', the ascii code etc but
> >it doesn't seem to work. 
> 
> Assuming that <r><ENTER> isn't what you want, type
> 
> 	Qs/search-pattern/\<ENTER>/<ENTER>vi<ENTER>

I have always used : to get the ex commands and the behaviour is different.
When using : the \<ENTER> doesn't work, instead you could use ^V

:s/search-pattern/^V^M/

symmetrically, ^V doesn't work if Q is used to get to ex!
-- 
Anthony Shipman                               ACSnet: als@bohra.cpg.oz.au
Computer Power Group
9th Flr, 616 St. Kilda Rd.,
St. Kilda, Melbourne, Australia
D

ires@kaspar.UUCP (Bruce R. Larson) (11/09/90)

In article <7103@ozdaltx.UUCP>, root@ozdaltx.UUCP (root) writes:
> ...                                     I beleive that there is a
> set flag in vi that allows 8 bit writing when saving a file.  Can't
> locate the code - anyone help?
> 
> Thanks in advance.....
>      scotty
>      root@ozdaltx
>

Try setting the ``nobeautify'' option.


Bruce R. Larson
Integral Resources, Milton MA
Internet: ires.com!blarson@cs.umb.edu
Uucp:     ..!cs.umb.edu!ires.com!blarson
========================================

pallen@sysp1.hq.af.mil (Pete Allen) (11/14/90)

In <7103@ozdaltx.UUCP> root@ozdaltx.UUCP (root) writes:

*>I have a few files that contain characters in the alternate character
*>set, that is greater than \177, mostly stuff to do ansi graphics for
*>boxes and such.  When I edit the file with vi, all of the codes are
*>stripped out and I get a plain text file.  I beleive that there is a
*>set flag in vi that allows 8 bit writing when saving a file.  Can't
*>locate the code - anyone help?

I'm also interested in that, because I'm trying to enter some escape/control
sequences and can't figure out how to do that either. Our man for vi is only
seven pages long and I wasn't able to find the answer there. I remember
having this problem with edlin on MS-DOS, and the answer was to enter ^v,
which it translated into the ESC thingie. I'l keep my eyes open.
--
==============================================================================
=  Pete Allen - N L 7 O I  =  _ //  =  If the Air Force WANTED me to have an =
=  pallen@sysp1.hq.af.mil  =  \X/   =  an opinion, they'd have ISSUED me one =
==============================================================================

enteles@tahoe.unr.edu (Philip Enteles) (11/19/90)

	First of all check to see if they are being stripped out or just not
being displayed. Use :set list to do this. If they are not there try
inputing them with the control v method. Type in a control v and then the
control letter you want. These two chars will appear as one. Also check to
make sure the beautify option is turned off. It strips out most control
chars. Hope this helps.

Philip Enteles
enteles@tahoe.unr.edu