knowledge-database (beta)

Current group: comp.editors

need help with vi command

need help with vi command  
Lex
 Re: need help with vi command  
Jehannes
 Re: [vi] deleting rest of lines by pattern (was: need help with vi command)  
Sven Guckes
 Re: need help with vi command  
tomlewton1 at hotmail.com
From:Lex
Subject:need help with vi command
Date:13 Jan 2005 02:07:13 -0800
Hi,
I am searching for the macro command in vi for doing this task which I
have to do otherwise manually.

For example, these are some lines of a file I need to work on

../client/source/tryst.cpp@@/main/KERNEL/TEST/0
../client/source/tryst.cpp@@/main/KERNEL/TEST/1
../client/source/tryst.cpp@@/main/KERNEL/TEST/2
../client/source/tryst.cpp@@/main/KERNEL/TEST/3

Now what I want to do is create a macro in "map" command so that with
one key stroke I get this output.

../client/source/tryst.cpp
../client/source/tryst.cpp
../client/source/tryst.cpp
../client/source/tryst.cpp

thanks in advance.

Lex
From:Jehannes
Subject:Re: need help with vi command
Date:13 Jan 2005 11:27:27 GMT
absolutelex@gmail.com (Lex) wrote in
news:30bc4139.0501130207.3a7e7fa6@posting.google.com:

> Hi,
> I am searching for the macro command in vi for doing this task which I
> have to do otherwise manually.
>
> For example, these are some lines of a file I need to work on
>
> ./client/source/tryst.cpp@@/main/KERNEL/TEST/0
> ./client/source/tryst.cpp@@/main/KERNEL/TEST/1
> ./client/source/tryst.cpp@@/main/KERNEL/TEST/2
> ./client/source/tryst.cpp@@/main/KERNEL/TEST/3
>
> Now what I want to do is create a macro in "map" command so that with
> one key stroke I get this output.
>
> ./client/source/tryst.cpp
> ./client/source/tryst.cpp
> ./client/source/tryst.cpp
> ./client/source/tryst.cpp
>
> thanks in advance.
>
> Lex
>


:%substitute/@@.*$//g does what you want.

:map :%substitute/@@.*$//g

maps this substitution to .




--
john@beeverWITHOUTTHIS.nl

= =
Sane sicut lux seipsam, & tenebras manifestat, sic veritas norma sui, &
falsi est.
-Spinoza-
= =
Posting powered by Vim 6.3 and ten fingers
vim.org
From:Sven Guckes
Subject:Re: [vi] deleting rest of lines by pattern (was: need help with vi command)
Date:13 Jan 2005 14:10:31 GMT
* Jehannes [2005-01-13]:
> absolutelex@gmail.com (Lex):
> [INPUT]
>> ./client/source/tryst.cpp@@/main/KERNEL/TEST/0
>> ./client/source/tryst.cpp@@/main/KERNEL/TEST/1
>> ./client/source/tryst.cpp@@/main/KERNEL/TEST/2
>> ./client/source/tryst.cpp@@/main/KERNEL/TEST/3
>>
>> [OUTPUT]
>> ./client/source/tryst.cpp
>> ./client/source/tryst.cpp
>> ./client/source/tryst.cpp
>> ./client/source/tryst.cpp
>
> :%substitute/@@.*$//g does what you want.
>
> :map :%substitute/@@.*$//g
> maps this substitution to .

's' suffices as the command name
and there will be at most one
match per line as it is anchored
with the end-of-line (EOL), so
the 'g' flag can be dropped:

:map :%s/@@.*$//

vi: there is no angle notation" in vi
(only elvis and vim), so you'll have to use
"#2" for the F2 key - and insert the CTRL-M
at the end litereal by typing CTRL-V CTRL-M:

:map #2 :%s/@@.*$//^M

caveat: make sure that the "@@"
really is unique in each line.

Sven
From:tomlewton1 at hotmail.com
Subject:Re: need help with vi command
Date:13 Jan 2005 03:28:33 -0800
sounds like sed would be more appropriate, not that you've made it all
that clear precisely what you want to achieve.
   

Copyright © 2006 knowledge-database   -   All rights reserved