Triplicate text after mix-matching vim and nvi

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Triplicate text after mix-matching vim and nvi

Ottavio Caruso
Hi,

Maybe this is off-topic but I hope you guys can help, as there's no
specific maling list for classic vi/nvi.

On my system (Linux/amd64 Debian 4.9.189) I have:

- vim (vim 8.1)
- vi (aliased to vim)
- nvi (nvi-1.81.6nb5 )

For self-educational purposes, I've been trying to teach myself to use
both vim and nvi, as I'm studying for a BSD-related certification,
where old vi is installed by default. So, to a certain extent, I am
looking for trouble, however...

I have a file (man-pages.txt) where I have a list of man pages that I
need to expand, for example:

man 8 tcpdump
man 1 login
man 8 sysctl
man 8 adduser
man 5 adduser.conf
man 8 rmuser
man 8 useradd
man 8 userdel

and so on. When I am finished with reading a man page, I cut the first
line and I paste to the last line, so:

1) dd
2) [shift] + g
3) p

And I've been doing this for a few months. Sometimes I use vim and
some other times nvi.

At one point, I noticed that the size of this file was growing
abnormally. Then, I realised that the entries were in duplicate or
triplicate copies, that is, as if I had copied the whole file and then
pasted it twice onto itself.

I removed the duplicate lines and started from scratch and, as a proof
of concept, alternated between vim and nvi, just to see if this would
happen again, and indeed it did.

I wonder if somebody has a clue why this happens. Is this something I
should expect? Is there a markup that one editor places that confuses
the other?

Thanks

--
Ottavio Caruso

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAEJNuHxa9%2BhNdpV4vq1FixmDg_-pbLF5WgZvFjMXDsKQv%2BGHTQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Triplicate text after mix-matching vim and nvi

Tony Mechelynck
On Tue, Feb 4, 2020 at 10:04 AM 'Ottavio Caruso' via vim_use
<[hidden email]> wrote:

>
> Hi,
>
> Maybe this is off-topic but I hope you guys can help, as there's no
> specific maling list for classic vi/nvi.
>
> On my system (Linux/amd64 Debian 4.9.189) I have:
>
> - vim (vim 8.1)
> - vi (aliased to vim)
> - nvi (nvi-1.81.6nb5 )
>
> For self-educational purposes, I've been trying to teach myself to use
> both vim and nvi, as I'm studying for a BSD-related certification,
> where old vi is installed by default. So, to a certain extent, I am
> looking for trouble, however...
>
> I have a file (man-pages.txt) where I have a list of man pages that I
> need to expand, for example:
>
> man 8 tcpdump
> man 1 login
> man 8 sysctl
> man 8 adduser
> man 5 adduser.conf
> man 8 rmuser
> man 8 useradd
> man 8 userdel
>
> and so on. When I am finished with reading a man page, I cut the first
> line and I paste to the last line, so:
>
> 1) dd
> 2) [shift] + g
> 3) p
>
> And I've been doing this for a few months. Sometimes I use vim and
> some other times nvi.
>
> At one point, I noticed that the size of this file was growing
> abnormally. Then, I realised that the entries were in duplicate or
> triplicate copies, that is, as if I had copied the whole file and then
> pasted it twice onto itself.
>
> I removed the duplicate lines and started from scratch and, as a proof
> of concept, alternated between vim and nvi, just to see if this would
> happen again, and indeed it did.
>
> I wonder if somebody has a clue why this happens. Is this something I
> should expect? Is there a markup that one editor places that confuses
> the other?
>
> Thanks
>
> --
> Ottavio Caruso

The following mapping will move the first line from top to bottom of
the file (at least in Vim in 'nocompatible' mode, I'm not sure about
vi (or 'compatible' Vim) and nvi):

:map <F5> :1d<Bar>$put<CR>

(<Bar> rather than | to avoid interpreting the rest when declaring the
mapping rather than when executing it). Of course you can use any
convenirnt {lhs} instead of <F5>

Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXszH_D3AKqVA7nRgckX0jO0WtSX4d4ACbNf7X7v%2BRB01Q%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Triplicate text after mix-matching vim and nvi

Christian Brabandt
In reply to this post by Ottavio Caruso

On Di, 04 Feb 2020, 'Ottavio Caruso' via vim_use wrote:

> Hi,
>
> Maybe this is off-topic but I hope you guys can help, as there's no
> specific maling list for classic vi/nvi.
>
> On my system (Linux/amd64 Debian 4.9.189) I have:
>
> - vim (vim 8.1)
> - vi (aliased to vim)
> - nvi (nvi-1.81.6nb5 )
>
> For self-educational purposes, I've been trying to teach myself to use
> both vim and nvi, as I'm studying for a BSD-related certification,
> where old vi is installed by default. So, to a certain extent, I am
> looking for trouble, however...
>
> I have a file (man-pages.txt) where I have a list of man pages that I
> need to expand, for example:
>
> man 8 tcpdump
> man 1 login
> man 8 sysctl
> man 8 adduser
> man 5 adduser.conf
> man 8 rmuser
> man 8 useradd
> man 8 userdel
>
> and so on. When I am finished with reading a man page, I cut the first
> line and I paste to the last line, so:
>
> 1) dd
> 2) [shift] + g
> 3) p
>
> And I've been doing this for a few months. Sometimes I use vim and
> some other times nvi.
>
> At one point, I noticed that the size of this file was growing
> abnormally. Then, I realised that the entries were in duplicate or
> triplicate copies, that is, as if I had copied the whole file and then
> pasted it twice onto itself.
>
> I removed the duplicate lines and started from scratch and, as a proof
> of concept, alternated between vim and nvi, just to see if this would
> happen again, and indeed it did.
>
> I wonder if somebody has a clue why this happens. Is this something I
> should expect? Is there a markup that one editor places that confuses
> the other?

Not sure what could be causing this. Note however, you can use the
`:copy` or `:t` alias. So to copy the first line to the last line, you
can simply do:

:1t$

Best,
Christian
--
Man muß wissen, daß der Krieg etwas Allgemeines ist, daß das Recht
auf dem Streit beruht und daß alles aus dem Streit und aus der
Notwendigkeit entsteht.
                -- Heraklit von Ephesus (540-480 v. Chr.)

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200204134327.GC12806%40256bit.org.
Reply | Threaded
Open this post in threaded view
|

Re: Triplicate text after mix-matching vim and nvi

Tim Chase
In reply to this post by Tony Mechelynck
On 2020-02-04 14:27, Tony Mechelynck wrote:
> The following mapping will move the first line from top to bottom of
> the file (at least in Vim in 'nocompatible' mode, I'm not sure about
> vi (or 'compatible' Vim) and nvi):
>
> :map <F5> :1d<Bar>$put<CR>

Or more simply

  :map <f5> :1m$<cr>

Should work in vi, vim, nvi, neovim, and the same concept/command in
ed(1).  It should also work regardless of your 'compatible' settings.
:-)

(within vim/neovim, I'd tend to use "nnoremap" instead of just "map")

-tim


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200204075241.1476df4a%40bigbox.attlocal.net.
Reply | Threaded
Open this post in threaded view
|

Re: Triplicate text after mix-matching vim and nvi

Tim Chase
In reply to this post by Christian Brabandt
On 2020-02-04 14:43, Christian Brabandt wrote:
> On Di, 04 Feb 2020, 'Ottavio Caruso' via vim_use wrote:
> > 1) dd
> > 2) [shift] + g
> > 3) p
>
> :1t$

That copies where Ottavio's command sequence moves, so he'd want

:1m$

:-)

-tim

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200204080459.0de24fad%40bigbox.attlocal.net.
Reply | Threaded
Open this post in threaded view
|

Re: Triplicate text after mix-matching vim and nvi

Christian Brabandt

On Di, 04 Feb 2020, Tim Chase wrote:

> On 2020-02-04 14:43, Christian Brabandt wrote:
> > On Di, 04 Feb 2020, 'Ottavio Caruso' via vim_use wrote:
> > > 1) dd
> > > 2) [shift] + g
> > > 3) p
> >
> > :1t$
>
> That copies where Ottavio's command sequence moves, so he'd want
>
> :1m$
>

Oh, yes he wanted to move and not copy. Sorry.

Best,
Christian
--
Es gibt Menschen, denen jedes Lob Tadel ist, das nicht das größte ist.
                -- Jean Paul

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200204141012.GD12806%40256bit.org.
Reply | Threaded
Open this post in threaded view
|

Re: Triplicate text after mix-matching vim and nvi

Tim Chase
In reply to this post by Ottavio Caruso
On 2020-02-04 09:03, 'Ottavio Caruso' via vim_use wrote:

> I have a file (man-pages.txt) where I have a list of man pages that
> I need to expand, for example:
>
> man 8 tcpdump
> man 1 login
> man 8 sysctl
> man 8 adduser
> man 5 adduser.conf
> man 8 rmuser
> man 8 useradd
> man 8 userdel

While I suggested using ":1m$" elsewhere in the thread, I'm glad I'm
not the only one doing something similar with man-pages.

However, I've used calendar programs to do this.  You can either use
the venerable calendar(1) format:

# BSD date(1)
$ d=$(date +%s);  while read line ; do printf '%s\t%s\n' $(date
-r $d +%Y-%m-%d ) "$line" ; d=$(( $d + (60*60*24) )); done <
list_of_manpages.txt >> ~/.calendar

# Linux date(1)
$ d=$(date +%s) ; while read line ; do printf '%s\t%s\n'
$(date --date="@$d" +%Y-%m-%d) "$line" ; d=$(( $d + (60*60*24) )) ;
done < list_of_manpages.txt >> ~/.calendar

(though beware that, if you have more than 365 entries, calendar(1)
seems to ignore the year)

You can then invoke

 $ calendar

(or put it in a cron-job if it's not automatically picked up by your
system scripts)

I do something similar using remind(1) which I prefer for calendaring:

  $ cat remify_manpages.awk
  BEGIN {
   print "SET ManStart date(2020,1,5)"
  }
  $7 ~ /^[1678]$/ {
   printf("REM [ManStart + %i] MSG man %s %%\"%s%%\"%%\n", NR - 1, $7,
  $6)
  }

  $ find /usr/share/man/man[1678]/ -maxdepth 2 -type f |
  grep -vi perl |
  sort -R |
  awk -F'[./]' -f remify_manpages.awk > manpages.rem

(I ignore the perl man-pages and randomly shuffle them)

and then invoking remind(1) will include my man-page-of-the-day for
that given date.

-tim




--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200204083930.5561f584%40bigbox.attlocal.net.
Reply | Threaded
Open this post in threaded view
|

Re: Triplicate text after mix-matching vim and nvi

Ottavio Caruso
In reply to this post by Tony Mechelynck
On Tue, 4 Feb 2020 at 13:27, Tony Mechelynck
<[hidden email]> wrote:

> The following mapping will move the first line from top to bottom of
> the file (at least in Vim in 'nocompatible' mode, I'm not sure about
> vi (or 'compatible' Vim) and nvi):
>
> :map <F5> :1d<Bar>$put<CR>
>
> (<Bar> rather than | to avoid interpreting the rest when declaring the
> mapping rather than when executing it). Of course you can use any
> convenirnt {lhs} instead of <F5>
>

Thanks. The remap works in vim but not in vi, probably because I'm
using the wrong syntax.

--
Ottavio Caruso

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAEJNuHx8ypGffZQGabrvoff0aM9yca5QxsL3JgkgGy1TcbkBAA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Triplicate text after mix-matching vim and nvi

Ottavio Caruso
In reply to this post by Christian Brabandt
On Tue, 4 Feb 2020 at 14:10, Christian Brabandt <[hidden email]> wrote:

>
>
> On Di, 04 Feb 2020, Tim Chase wrote:
>
> > On 2020-02-04 14:43, Christian Brabandt wrote:
> > > On Di, 04 Feb 2020, 'Ottavio Caruso' via vim_use wrote:
> > > > 1) dd
> > > > 2) [shift] + g
> > > > 3) p
> > >
> > > :1t$
> >
> > That copies where Ottavio's command sequence moves, so he'd want
> >
> > :1m$
> >
>
> Oh, yes he wanted to move and not copy. Sorry.

Tim & Christian,

the command works in both vim and nvi. The remap only in vim. I'll try
to find a way of making it work in nvi, but this would be off topic.

(BTW: if anybody knows a of a vi/nvi mailing list or usenet group,
please let me know, on of off list)

--
Ottavio Caruso

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAEJNuHwe6cXd%2BRNQOuzmm1-16uZ2DCJA8WFbV5mkQT_SSRf7Ow%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Triplicate text after mix-matching vim and nvi

Ottavio Caruso
On Wed, 5 Feb 2020 at 08:38, Ottavio Caruso
<[hidden email]> wrote:

>
> On Tue, 4 Feb 2020 at 14:10, Christian Brabandt <[hidden email]> wrote:
> >
> >
> > On Di, 04 Feb 2020, Tim Chase wrote:
> >
> > > On 2020-02-04 14:43, Christian Brabandt wrote:
> > > > On Di, 04 Feb 2020, 'Ottavio Caruso' via vim_use wrote:
> > > > > 1) dd
> > > > > 2) [shift] + g
> > > > > 3) p
> > > >
> > > > :1t$
> > >
> > > That copies where Ottavio's command sequence moves, so he'd want
> > >
> > > :1m$
> > >
> >
> > Oh, yes he wanted to move and not copy. Sorry.
>
> Tim & Christian,
>
> the command works in both vim and nvi. The remap only in vim. I'll try
> to find a way of making it work in nvi, but this would be off topic.

Correction: I had to prefix the maps with [ctrl]+v and now it works on nvi too:

nvi:
map ^[[15~ :1m$^M

vim:
map <f5> :1m$<cr>

Thanks Tony, Christian and Tim!


--
Ottavio Caruso

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAEJNuHziw5NHqJYsTMPPCnD7Md%3DLBCKx2tV7Okq%2B7%3DY8r7X8%3DA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Triplicate text after mix-matching vim and nvi

Tim Chase
In reply to this post by Ottavio Caruso
On 2020-02-05 08:38, 'Ottavio Caruso' via vim_use wrote:
> the command works in both vim and nvi. The remap only in vim. I'll
> try to find a way of making it work in nvi, but this would be off
> topic.

Ah, good point.  The "<f5>" notation is a vim thing.  You can either
use some other key such as "Q"

  :map Q :1m$^M

where ^M is entered using control+V followed by control+M

(just tested in the nvi that I have here on FreeBSD)

Alternatively, if you know the escape sequence for the key you want
such as F5, you might be able to enter it literally, escaping with
control+V as above.

(as I type this, your follow-up email arrived where you do just that)

> (BTW: if anybody knows a of a vi/nvi mailing list or usenet group,
> please let me know, on of off list)

I think this list is the closest there is.  I regularly use vi/nvi,
vim, and ed(1), and occasionally neovim.  I'm sure there are others.
There's enough overlap between vi/nvi and vim/neovim that even if
you're asking questions about vi/nvi here, you'll hopefully get some
good answers.  It also helps get relevant answers if you mention that
your question is about vi/nvi instead of vim, so folks don't try to
reply with vim-specific answers.

-tim


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200205072126.224f67a3%40bigbox.attlocal.net.
Reply | Threaded
Open this post in threaded view
|

Re: Triplicate text after mix-matching vim and nvi

Ottavio Caruso
In reply to this post by Ottavio Caruso
On Tue, 4 Feb 2020 at 09:03, Ottavio Caruso
<[hidden email]> wrote:

>
>
> At one point, I noticed that the size of this file was growing
> abnormally. Then, I realised that the entries were in duplicate or
> triplicate copies, that is, as if I had copied the whole file and then
> pasted it twice onto itself.
>
> I removed the duplicate lines and started from scratch and, as a proof
> of concept, alternated between vim and nvi, just to see if this would
> happen again, and indeed it did.
>
> I wonder if somebody has a clue why this happens. Is this something I
> should expect? Is there a markup that one editor places that confuses
> the other?

For the record, the culprit is nvi (and mate-terminal).

When mate-terminal crashes (and this should not happen) obviously also
nvi crashes. For some reason, nvi creates multiple recovery files in
/tmp (and this shouldn't happen either).

So, for the time being, I have abandoned my educational purposes and
will stick with vim.

Thanks for making a great editor.


--
Ottavio Caruso

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAEJNuHywJ-oDxqQ%3DwrC0ifqtiQ0AC_XheS69Gq%3DgLbHsJOFGAw%40mail.gmail.com.