How to with (n)vi ...

A working solution (of sorts) for your "\n" problem in vi, is also utilising sed as an external filter:
:%!sed -ne '1h;2,$H;$g;$s/abc\ndef/abcdef/gp'
This dumps the complete file in the pattern space (treating it as one line) and then uses it for the substitution; to me that feels like a hack. This also defeats the "stream" aspect of sed as a stream editor.
Look ssam from plan9port: "ssam - stream interface to sam".

With it looks less than a hack.
 
...
Another question:

"%s/abc/ABC/2" should substitute in every line the second occurrence of "abc" with "ABC".
...
in vim :
:%s/\(\(.*\)\(abc\)\(.*\)\)\@<=abc/ABC/
The '/g' modifier is not needed.

This works with the example from post #19 :
Code:
this is line abc, abc, abc and abc
def this abc line, abc line and still abc line.
this is line abc, abc, abc and abc
def this abc line, abc line and still abc line.

In each line of text, only the second (not the first, third, fourth, etc.) 'abc' subsequence will be replaced.

Maybe it will work in your editor.
 
Maybe it will work in your editor.
Well, the question had no practical use, it was only to try to understand what I thought to be contradiction with the
documentation. Erichans answer solved it.

Well, when I use the editor, I want to concentrate in what I write, not in how to make the editor write what I want.
If I really need to do that, I would use ed.
 
Do someone knows how to make work nvi's
^]
:tag
:Tag
with cscope?

According to page 13.8 in


they should work, but nvi tries to find the tag in the file tags (ctags).

Unfortunately, if one search for something about vi or nvi in google, one only finds info on vim, for example:


But nvi does not have this configuration option.

Any hint?
 
I found this:

I even fixed some broken stuff in nvi-1.79, like the cscope support.
It's marked as an feature of nvi but it never worked actually...


I cannot judge the quality of the fork, but interesting to see that he found a bug with cscope.

BTW, :tagnext, :tagprevious, :tagpop, :tagtop and ^T do work with cscope. ":cscope find" hangs from time to time.
The bigger problem is with :tag and ^], as written above.
 
It is not compiled in packages to test it.
My ports collection is old and I get the message that my perl is not the right version.
I do not want to install the ports with git, it takes too much time to download, only for a test.

OpenBSD has nvi 1.79, not multilingual, but it has not the old cscore interface that is documented in viref.

In reality, I do not like the implementation that keep a cscore process alive and communicates with it,
I think it should be possible with a call every time needed. And perhaps there is a way to implement
something more general, configurable, to call similar databases.
 
You seem to be going through a lot of trouble for something that at least 85% can be achieved via standalone tools. i.e:

Code:
$ grep -R uvToWorld
    main.cpp: * uvToWorld
    main.cpp:glm::vec3 uvToWorld(const Triangle& t, const glm::vec2& uv)
    main.cpp:  glm::vec3 res = uvToWorld(t, uv);
    main.cpp:  res = uvToWorld(t, uv);

Perhaps you could script around ctags and cscope to create a command that is more precise / informative than grep. cscope itself can run standalone.

If you are looking to compile up another version of (n)vi in the hope that this feature has been corrected; perhaps try out OpenVi. I tend to grab that when on Cygwin/Linux. I don't know if it has the fixes you need though. Very easy to compile, doesn't need crap like perl.
 
You seem to be going through a lot of trouble for something that at least 85% can be achieved via standalone tools.
No, no trouble, just asking how to do it and pointing to a possible bug.

An yes, cscope as stand alone tool can call vi, it is very practical. But more practical is the nvi tag mechanism that
according to documentation should also work with scope: you just type ^] over a symbol and a new screen pointing
to the symbol should open, the old goes to stack, with :tagn you can find other occurrences of the sysmbl. You can
map :tagn and :tagpr to control key to navigate more easily.

If you are looking to compile up another version of (n)vi in the hope that this feature has been corrected;

No, I am not looking for that. I am interested in nvi because it is by default in the system.
 
cscope as stand alone tool can call vi, it is very practical. But more practical is the nvi tag mechanism that
according to documentation should also work with scope: you just type ^] over a symbol and a new screen pointing
to the symbol should open, the old goes to stack, with :tagn
"also work with scope"; is that a typo and shouldn't that be cscope (as in devel/cscope)?

As I read Bostic's ref at "8. Tags, Tag Stacks, and Cscope", tagnext (tagn) and tagprev (tagp) are two nvi commands only intended to be used with cscope(1)
 
"also work with scope"; is that a typo and shouldn't that be cscope (as in devel/cscope)?

Yes, a typo.

As I read Bostic's ref at "8. Tags, Tag Stacks, and Cscope", tagnext (tagn) and tagprev (tagp) are two nvi commands only intended to be used with cscope(1)

No, tagn[ext] and tagpr[evious] (tagp is tagpop, not tagprevious) also work with normal tags file
if you have many lines with the same tag in it. But BSD's ctags (1) does not generate such a tags file.

And yes, tagn and tagpr are working with cscope, as ^T, tagpop, tagtop.
Only :tag :Tag and ^] are not working with cscope.

As said, it would be interesting to have a more general, configurable mechanism to call external dbs with tags.
At best call once as needed and not IPC to a process as is now the case with cscope interface.
 
Back
Top