Re: Requesting vi tips

2019-10-20 Thread adr

marks are fairly useful and easy to define, though traditional
vi doesn't keep them when swapping buffers, unfortunately.
... that's one of the main reasons why I've upgraded to vim. That
and v, and multiple buffers visible at the same time.


Just for the record, to not confuse the OP, vi in Openbsd is nvi.

Nvi can display multiple buffers (they are called screens) splitting
the screen.

Nvi keeps the marks between screens when they are views of the same
file.

About v, I mark the starting position with ms. Then move around
and use `s`` to see what I have.

regards,
adr



Re: Requesting vi tips

2019-10-20 Thread Marc Espie
On Fri, Oct 18, 2019 at 03:45:42PM +0100, cho...@jtan.com wrote:
> Claudio Jeker writes:
> > set wl=72 will limit the line lenght to around 72. Additionally you
> > can use !fmt with movement chars to reformat sections. I use !{fmt
> > or {!}fmt frequently to reformat the paragraph I'm in.
> 
> I didn't know [how] ! took movement commands. Thanks. I'll have a play
> with that one.

About everything in vi takes movement commands.  That includes !
or > or <, among others.

And there are lots of useful movement commands, % being one of the most
often forgotten.

marks are fairly useful and easy to define, though traditional vi doesn't
keep them when swapping buffers, unfortunately.

... that's one of the main reasons why I've upgraded to vim. That and v,
and multiple buffers visible at the same time.



Re: Requesting vi tips

2019-10-19 Thread adr

You like emacs, so in .exrc

map ^[q }{!}fmt -72 -s^M}

The ^[ is an escape character, entered with the sequence C-vEsc.
I think that your Meta key will produce one.

C-v produce the character 0x16, used by nvi as , a
character to escape other characters.

The ^M is a , entered with the sequence C-vEnter,
or C-vC-M.

The } before {!  is to format the next paragraph if we are not
already in one, just like M-q in emacs.

For the whole buffer you can use something like this (as other
pointed before)

map =F %!fmt -72 -s^MG

The % is an abbreviation of "1,$", a range of the whole buffer. There
are some tricky ones like using regular expresions. Ranges aren't
described in the man page.

This is the nvi reference manual. It will be handy:

https://docs.freebsd.org/44doc/usd/13.viref/paper.pdf

When you are playing with maps, remember that a | in a map can be
entered without any escaping if you are using directly the map
command, I mean, you entered ex mode with : and then type map...
If you save the maps with :mkexrc they will be fine. You can write
pipes and they will work, for example. But if you are editing
directly your exrc, they will be treated like ex command separators.
You have to write before a literal , that is the
sequence C-vC-v|

This is not documented anywhere. At least to my knowledge.


And that's my way to say sorry for been an asshole.

adr.



Re: Requesting vi tips

2019-10-18 Thread Christian Weisgerber
On 2019-10-18, Nam Nguyen  wrote:

>> Since 'q' is unused in nvi, I have this in my .nexrc:
>> map q !}fmt
>
> I just wanted to add that you can Ctrl-v Enter to produce the ^M at the end.
> This way it inputs and executes the command for you.
> 
> It could be like this if you want it to press Enter for you:
> map q !}fmt^M

And upon closer inspection I see that's what I actually have in my
.nexrc; less(1) didn't show the ^M and I had forgotten about it.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



Re: Requesting vi tips

2019-10-18 Thread Nam Nguyen
On 2019-10-18, Christian Weisgerber wrote:
> On 2019-10-18, cho...@jtan.com wrote:
>
>> I didn't know [how] ! took movement commands. Thanks. I'll have a play
>> with that one.
>>
>> It's not quite M-q (it's M not C) but I'm using vi after all.
>
> Since 'q' is unused in nvi, I have this in my .nexrc:
>
> map q !}fmt
>
> Close enough to emacs's M-q.
>

I just wanted to add that you can Ctrl-v Enter to produce the ^M at the end.
This way it inputs and executes the command for you.

It could be like this if you want it to press Enter for you:
map q !}fmt^M

I like joining lines before using fmt on a single line, hence the '.'. I had
forgotten about the '}' motion and may need to incorporate that. I also did not
know that the ':' can be omitted.

I currently use:
map gq :.!fmt -w 72^M
map q0 :.!fmt -w 77^M
map q1 :.!fmt -w 69^M
map q2 :.!fmt -w 61^M
map q3 :.!fmt -w 53^M
map qq :.!fmt -w 80^M



Re: Requesting vi tips

2019-10-18 Thread adr

On Fri, 18 Oct 2019, cho...@jtan.com wrote:


For the record, I have a finite amount of neurons with a correspondingly
finite amount of synapses. There is only so much even I can hold
in my head. Asking actual humans for access to the particular
minutiae they happen to have itemised to the nth unnecessary degree
for obscure factoids that might be found helpful is a valid strategy.


That is the dumbest thing I've ever heard. Turn your computer in.
You are incapable of handling one.

I told you, is so easy.



Re: Requesting vi tips

2019-10-18 Thread chohag
adr writes:
> You see, is so easy to be an asshole.

You're telling me?

I know I'm not particularly active on OpenBSD's mailing lists but
I've certainly been around.

For the record, I have a finite amount of neurons with a correspondingly
finite amount of synapses. There is only so much even I can hold
in my head. Asking actual humans for access to the particular
minutiae they happen to have itemised to the nth unnecessary degree
for obscure factoids that might be found helpful is a valid strategy.

Matthew



Re: Requesting vi tips

2019-10-18 Thread Raf Czlonka
On Fri, Oct 18, 2019 at 03:39:41PM BST, cho...@jtan.com wrote:
> Raf Czlonka writes:
> > On Fri, Oct 18, 2019 at 03:12:37PM BST, cho...@jtan.com wrote:
> > Is this what you had in mind?
> >
> > set editor="EXINIT='set wraplen=72' /usr/bin/vi"

I forgot to mention - this is the line in my muttrc(5).

> I'm not sure that I'm happy with it doing it mid-insert. I'd prefer an
> explicit action or insert mode itself being adapted so that it includes
> a final reformat (ie. when I press escape (if the appropriate flag is
> enabled)).

Then I clearly misunderstood what you meant.

> Also it has the fault that if, say, the 4th character of a word causes a
> line break, then reducing that word to less than 4 characters doesn't
> remove it (although the newline can be deleted as though it were
> inserted as usual, which is good).
> 
> Matthew
> 

As others have already mentioned - fmt(1) from base... or par(1)
from ports.

Regards,

Raf



Re: Requesting vi tips

2019-10-18 Thread adr

I didn't know [how] ! took movement commands. Thanks. I'll have a play
with that one.

It's not quite M-q (it's M not C) but I'm using vi after all.

Matthew


The entire man page is 1332 widely-spaced-out lines of clear, simple
formated text. Including comments. Read the damn thing.

You see, is so easy to be an asshole.

adr.



Re: Requesting vi tips

2019-10-18 Thread Christian Weisgerber
On 2019-10-18, cho...@jtan.com  wrote:

> I didn't know [how] ! took movement commands. Thanks. I'll have a play
> with that one.
>
> It's not quite M-q (it's M not C) but I'm using vi after all.

Since 'q' is unused in nvi, I have this in my .nexrc:

map q !}fmt

Close enough to emacs's M-q.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



Re: Requesting vi tips

2019-10-18 Thread Frank Beuth

On Fri, Oct 18, 2019 at 03:12:37PM +0100, cho...@jtan.com wrote:

Alternatively is there something that would make vi do it on the fly, or
something akin to emacs' C-q or vim's gq. Although I appreciate the fact
that vi doesn't try to be clever.


1) select all text in visual mode (e.g with V, then gg)
2) :!fmt -w 72

disclaimer: vi is aliased to vim on my system so apologies if this
doesn't work



about vim objects (Re: Requesting vi tips)

2019-10-18 Thread Marc Chantreux
hello,

> I didn't know [how] ! took movement commands. Thanks. I'll have a play
> with that one.

almost related: in addition to the motions, vim has a notion of objects

:h objects

so you can easily filter a complete paragraph with

!ap
fmt -w72

in visual mode, you can select nested objects by adding a selection

{ // the whole code
{ // the object i want to select
{
you are here
}
}
}

you can select the expected object using va{a{

HTH
marc



Re: Requesting vi tips

2019-10-18 Thread paul wisehart
On Fri, Oct 18, 2019 at 03:12:37PM +0100, cho...@jtan.com wrote:
>  but I wonder if there's something that can correctly parse the
> whole email and format the entire thing en masse 

:%!fmt -s



Re: Requesting vi tips

2019-10-18 Thread chohag
Claudio Jeker writes:
> set wl=72 will limit the line lenght to around 72. Additionally you
> can use !fmt with movement chars to reformat sections. I use !{fmt
> or {!}fmt frequently to reformat the paragraph I'm in.

I didn't know [how] ! took movement commands. Thanks. I'll have a play
with that one.

It's not quite M-q (it's M not C) but I'm using vi after all.

Matthew



Re: Requesting vi tips

2019-10-18 Thread chohag
Raf Czlonka writes:
> On Fri, Oct 18, 2019 at 03:12:37PM BST, cho...@jtan.com wrote:
> Is this what you had in mind?
>
>   set editor="EXINIT='set wraplen=72' /usr/bin/vi"

I'm not sure that I'm happy with it doing it mid-insert. I'd prefer an
explicit action or insert mode itself being adapted so that it includes
a final reformat (ie. when I press escape (if the appropriate flag is
enabled)).

Also it has the fault that if, say, the 4th character of a word causes a
line break, then reducing that word to less than 4 characters doesn't
remove it (although the newline can be deleted as though it were
inserted as usual, which is good).

Matthew



Re: Requesting vi tips

2019-10-18 Thread Claudio Jeker
On Fri, Oct 18, 2019 at 03:12:37PM +0100, cho...@jtan.com wrote:
> OK this has started to get on my nerves now.
> 
> I use vi to enter emails despite using evil emacs for development and
> other general editing. Rather than linking them together (they're on
> seperate machines) to enter emails in emacs I'd rather figure out
> something interesting about vi.
> 
> At the moment I limit lines to 72 characters through a laborious process
> of finding the appropriate space character myself and replacing it with
> a ^M. Obviously nonsense which is why I sometimes don't bother. (Sorry).
> 
> I know about fmt and could easily concoct the pipeline to format each
> paragraph but I wonder if there's something that can correctly parse the
> whole email and format the entire thing en masse without me writing what
> would undoubtedly be Yet Another Poor Implementation.
> 
> Alternatively is there something that would make vi do it on the fly, or
> something akin to emacs' C-q or vim's gq. Although I appreciate the fact
> that vi doesn't try to be clever.
> 

set wl=72 will limit the line lenght to around 72. Additionally you
can use !fmt with movement chars to reformat sections. I use !{fmt
or {!}fmt frequently to reformat the paragraph I'm in.

-- 
:wq Claudio



Re: Requesting vi tips

2019-10-18 Thread Raf Czlonka
On Fri, Oct 18, 2019 at 03:12:37PM BST, cho...@jtan.com wrote:
> OK this has started to get on my nerves now.
> 
> I use vi to enter emails despite using evil emacs for development and
> other general editing. Rather than linking them together (they're on
> seperate machines) to enter emails in emacs I'd rather figure out
> something interesting about vi.
> 
> At the moment I limit lines to 72 characters through a laborious process
> of finding the appropriate space character myself and replacing it with
> a ^M. Obviously nonsense which is why I sometimes don't bother. (Sorry).
> 
> I know about fmt and could easily concoct the pipeline to format each
> paragraph but I wonder if there's something that can correctly parse the
> whole email and format the entire thing en masse without me writing what
> would undoubtedly be Yet Another Poor Implementation.
> 
> Alternatively is there something that would make vi do it on the fly, or
> something akin to emacs' C-q or vim's gq. Although I appreciate the fact
> that vi doesn't try to be clever.
> 
> Thanks,
> 
> Matthew
> 

Is this what you had in mind?

set editor="EXINIT='set wraplen=72' /usr/bin/vi"

Regards,

Raf



Requesting vi tips

2019-10-18 Thread chohag
OK this has started to get on my nerves now.

I use vi to enter emails despite using evil emacs for development and
other general editing. Rather than linking them together (they're on
seperate machines) to enter emails in emacs I'd rather figure out
something interesting about vi.

At the moment I limit lines to 72 characters through a laborious process
of finding the appropriate space character myself and replacing it with
a ^M. Obviously nonsense which is why I sometimes don't bother. (Sorry).

I know about fmt and could easily concoct the pipeline to format each
paragraph but I wonder if there's something that can correctly parse the
whole email and format the entire thing en masse without me writing what
would undoubtedly be Yet Another Poor Implementation.

Alternatively is there something that would make vi do it on the fly, or
something akin to emacs' C-q or vim's gq. Although I appreciate the fact
that vi doesn't try to be clever.

Thanks,

Matthew