Thursday, December 31, 2020

Spell check: ignoring soft hyphens

Apologies if this is a basic question, but I've read the documentation
on spelling multiple times and must be missing the answer. Ive also
checked the FAQ and the group archives.

GVim 7.4, running in Windows 7 and 8. I use only 8-bit characters, in
Windows-1252 encoding (set enc=latin1 in Vim).

My question: I frequently use the soft hyphen (character 173, or 255
in octal) in HTML documents. How can I tell Vim to ignore these
characters for purposes of spell check?

For example, I want Vim to consider "pur<173>pose" as a good word
because "purpose" is a good word. I don't expect Vim to know what is
correct syllabication, just to ignore any soft hyphen when it's deciding
whether a word is spelled correctly.

Currently I handle this by putting "pur<173>pose" in my word list
file, but obviously I don't want to do that with every possible
hyphenation of every possible good word.

--
Stan Brown
Tehachapi, CA, USA
https://BrownMath.com
https://OakRoadSystems.com

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/1f27dc28-16bd-5e42-c300-2098f762db58%40fastmail.fm.

Wednesday, December 30, 2020

Vim calendar for 2021 available

Happy New Year to all Vim users!

2020 was a strange year, different from what we are used to and not what
we hoped for. Not being able to travel I did manage to spend more time
on Vim. As the activity overview on Github shows, I have submitted at
least one Vim patch every day in 2020!

Work on Vim9 script has made good progress, many choices have been made
and a large part of the implementation is done. The home stretch will
still take time, once launched we have to be backwards compatible again,
there is only one chance to make breaking changes.

I have updated the handy desktop calendar for 2021. It prints on one
sheet of paper and, after folding and applying a bit of glue, stands on
your desk.

It is available in English and Dutch. You can find the PDF files on my
website: https://moolenaar.net/#Calendar

Happy Vimming!

--
Never go to the toilet in a paperless office.

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/202012301955.0BUJt64U1023335%40masaka.moolenaar.net.

vim-scripts/Add-to-Word-Search

I use the plugin: inkarkat/vim-SearchHighlighting

One of its features I really like is '*' does not advance the cursor to the next matching word.

Another plugin I use is: vim-scripts/Add-to-Word-Search
This allows easily adding new words to a search with <Leader>**
It works great, but it advances the cursor to the next matching word.

Are the better plugins for this purpose? Or has anyone modified Add-to-Word-Search to not advance after adding a new word?

Thanks!


--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/9ab0ca0f-0f3c-4d15-a40e-408bf0916112n%40googlegroups.com.

Re: vim9script syntax indent/comment recognition

> It seems when I open a well formed vim9script that no recognition is
> working to:
>
> 1. indent def function and block corpus of function
> 2. new line of comment precedeed by # char at beginning of line.

Do you have the latest indent/vim.vim file? Dated "2020 Sep 27".

--
"Oh, no! NOT the Spanish Inquisition!"
"NOBODY expects the Spanish Inquisition!!!"
-- Monty Python sketch --
"Oh, no! NOT another option!"
"EVERYBODY expects another option!!!"
-- Discussion in vim-dev mailing list --

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/202012301300.0BUD0weY924529%40masaka.moolenaar.net.

vim9script syntax indent/comment recognition

Hi all,

It seems when I open a well formed vim9script that no recognition is working to:
  1. indent def function and block corpus of function
  2. new line of comment precedeed by # char at beginning of line.

best wishes to all.
NiVa

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/231d83a7-a764-442e-aea3-a9acf87243fen%40googlegroups.com.

Tuesday, December 29, 2020

Working with events in itchyny's calendar.vim

Hello,

Started looking at itchyny's caledar.vim.

First, I love the idea of "Vim as an application platform" -- this is
similar to my "Editable User Interface (EUI, eui_vim) : The use of a
text editor as the user interface to applications"
https://www.vim.org/scripts/script.php?script_id=906

Please help resolve these issues:

1) The views shown with > stop at the clock -- help says that after the
clock-view, there will be the event-view.

2) Pop-up that results from hitting E has the heading "3 PM" -- what is
this, how can it be changed?

3) In the pop-up from hitting E and in the time-line of the day-view,
the events are listed in order of time. However, in the list of events
for the day, the events are listed in the order in which they were
entered. How to fix this?

Thanks,

--Suresh

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/93287798-b305-00af-ed31-483d7636cea6%40yahoo.com.

Re: Bug in help docs?

Kenny Stauffer wrote:

> The help for CTRL-\_CTRL-N says: "When focus is in a terminal window,
> CTRL-\ CTRL-N goes to Normal mode for only one command, see
> |t_CTRL-\_CTRL-N|."
>
> The part about "for only one command" doesn't seem to be true. Vim stays in
> Terminal-Normal mode for multiple normal mode commands (yank, mark) and ex
> commands (:checktime). The help for t_CTRL-\_CTRL-N does not mention "for
> only one command." Am I failing to understand what help is trying to tell
> me? Or is this a bug in the docs?

This is a mistake in the help. If you follow the tag then it just
mentions going to Normal mode.

--
Bumper sticker: Honk if you love peace and quiet.

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/202012291147.0BTBlHGV609511%40masaka.moolenaar.net.

Monday, December 28, 2020

Re: Matching a non-match

In a simple test file, this did what I think you're asking:    /\v^(.*exim[/]input)@!

Notice the use of @! instead of @<!

On Sunday, December 20, 2020 at 6:09:47 AM UTC-5 A. Wik wrote:
Hi all,

Browsing a directory listing, sometimes I hit lines like these:
./spool/exim/input/1FM8sl-00004n-Ix-H
./spool/exim/input/1FM8sn-00004u-OF-D
./spool/exim/input/1E9dsQ-00004f-MO-D
[... thousands of similar lines ...]

How can I use "/" to find the next line not matching the above
pattern? I've tried the following (and several variations):
/\(.*exim.input\)\@<!.*

Regards,
Albert Wik.

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/47986bcd-3a6e-4849-bbff-1f92366d7c8an%40googlegroups.com.

Bug in help docs?

The help for CTRL-\_CTRL-N says: "When focus is in a terminal window, CTRL-\ CTRL-N goes to Normal mode for only one command, see |t_CTRL-\_CTRL-N|."

The part about "for only one command" doesn't seem to be true. Vim stays in Terminal-Normal mode for multiple normal mode commands (yank, mark) and ex commands (:checktime). The help for t_CTRL-\_CTRL-N does not mention "for only one command." Am I failing to understand what help is trying to tell me? Or is this a bug in the docs?

Thanks,
Kenny

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/4b79aa62-a668-4e9f-83fc-742e506baed6n%40googlegroups.com.

Re: Jump between phrases with particular pattern and feed matching words to command

On Sun, Dec 27, 2020 at 03:20:01PM +0100, 'Fetchinson' via vim_use wrote:
>> I have a text file with content like this:
>>
>> [example.jpg|image]
>> [example.pdf|document]
>> [another.jpg|image]
>> [yetanother.doc|document]
>>
>> And I'd like to make vim "jump" between the 4 items back and forth via
>> two selected keys, for example "n" for next and "p" for previous. When
>> one of the items is "selected", it should be highlighted with a
>> background different from the default, I mean the whole item from [ to
>> ] should have a different background. Then I'd like to be able to
>> press a third key, for example, Enter, which should call a vim
>> function with the 2 arguments given by the file name and the file
>> type, for example "example.pdf" and "document".

You can achieve the first two goals with 'j', 'k', and the cursorline setting.

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201228162930.GA30924%40rainslide.net.

Sunday, December 27, 2020

Re: Jump between phrases with particular pattern and feed matching words to command

> I have a text file with content like this:
>
> [example.jpg|image]
> [example.pdf|document]
> [another.jpg|image]
> [yetanother.doc|document]
>
> And I'd like to make vim "jump" between the 4 items back and forth via
> two selected keys, for example "n" for next and "p" for previous. When
> one of the items is "selected", it should be highlighted with a
> background different from the default, I mean the whole item from [ to
> ] should have a different background. Then I'd like to be able to
> press a third key, for example, Enter, which should call a vim
> function with the 2 arguments given by the file name and the file
> type, for example "example.pdf" and "document".
>
> How would I go about achieving this?

What I'm looking for is a kind of browser-like behavior like
NERD_tree.vim but this is over 4000 lines of code and I couldn't
figure out how it does what it does.

Cheers,
Daniel

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CADjSo4SEUe80quaZiPoPXJtKr0x3Fu4-PzfaohXLaPAw9y4aFQ%40mail.gmail.com.

Saturday, December 26, 2020

Jump between phrases with particular pattern and feed matching words to command

Hi everybody,

I have a text file with content like this:

[example.jpg|image]
[example.pdf|document]
[another.jpg|image]
[yetanother.doc|document]

And I'd like to make vim "jump" between the 4 items back and forth via
two selected keys, for example "n" for next and "p" for previous. When
one of the items is "selected", it should be highlighted with a
background different from the default, I mean the whole item from [ to
] should have a different background. Then I'd like to be able to
press a third key, for example, Enter, which should call a vim
function with the 2 arguments given by the file name and the file
type, for example "example.pdf" and "document".

How would I go about achieving this?

--
Psss, psss, put it down! - http://www.cafepress.com/putitdown

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CADjSo4SKp83eXjPAn6xoqEGj12OVMakyVg0kT-kh%3DAJ7JOT6uA%40mail.gmail.com.

Re: Getting the current character position of the cursor


On Sat, Dec 26, 2020 at 8:58 AM Yegappan Lakshmanan <yegappanl@gmail.com> wrote:
Hi,

The getcurpos() and col() functions return the byte position of the cursor.
Is there a function that returns the character position of the cursor in
the current line?

The byteidx() function returns the byte index given the character index
in a string. I am looking for the opposite.


Neovim has the vim.str_utfindex() function that returns the character
index of a given byte index in a string:


I am looking for a similar function to use in Vim.

- Yegappan
 

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAAW7x7knwTHiTa-8%2BcCnMceQDPgx6pXxU_kDzvN1TbAuGCsg9w%40mail.gmail.com.

Getting the current character position of the cursor

Hi,

The getcurpos() and col() functions return the byte position of the cursor.
Is there a function that returns the character position of the cursor in
the current line?

The byteidx() function returns the byte index given the character index
in a string. I am looking for the opposite.

Thanks,
Yegappan

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAAW7x7nER5%2BrkybiqZ%3Dq4EwaamaAcv59g%2BUfnYx0V%3Dh%3D_ih2jQ%40mail.gmail.com.

Friday, December 25, 2020

Re: complex-repeat Behavior Changed Recently

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Friday, December 25th, 2020 at 5:43 AM, Tim Chase <vim@tim.thechases.com> wrote:

> On 2020-12-22 19:43, 'JB' via vim_use wrote:
>
> > Typing 'qa0xxj' and executing macro 'a' used to go to the beginning
> >
> > of the line, delete the first two chars, then jump down one line.
> >
> > Now, the cursor goes to the beginning of the line and execution of
> >
> > the macro stops -- no deletions or jumping down one line. The same
> >
> > when using '^' or '$'. Leaving out the movement to the beginning or
> >
> > end of the line results in the expected behavior: the macro is
> >
> > executed completely. What gives?
>
> A few things occur to me:
>
> 1. are you doing this in a stock vim? Or do you have some
>
> plugin/mapping that might be interfering? I just tried it here and
>
> it worked fine. Can you replicate within
>
> $ vim -u NONE
> 2. are you doing it on a blank line where the first "x" would fail,
>
> stopping the rest of the macro's execution?
> 3. (kinda part of #1) do you happen to have some strange mapping for
>
> "0x" that would interfere with the playback? If you manually type
>
> 0xx
>
> does it work for you outside a macro?
> 4. you are executing this in Normal mode, not some other mode, right?
>
> -tim
>
> --

Hi Tim,

I've solved this already, but you were on the right track. The offending lines
in my .vimrc were:

nn 0 ^ | " goto first non-blank char in line
nn ^ 0 | " goto start of line

Replacing the <Tab><Tab> characters preceding the pipes with spaces fixed it.
Executing the Normal command outside of a macro worked fine, but inside a macro failed.
My original mapping used to work, but recently broke.

Solved it by typing ':nn', which listed my Normal noremap-s and showed the <Tab> chars.

Thanks for helping.

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/gv79idOZmE3gVf8f3MR8TLSZEHCh8wlxvWxHBCl72hWflWj4WrclOKMOQXyaEO9HltuvJQQdRPqkIaESF3VlqIl2pgfPMoZ5fIgnlCEKDac%3D%40protonmail.com.

Re: complex-repeat Behavior Changed Recently

On 2020-12-22 19:43, 'JB' via vim_use wrote:
> Typing 'qa0xxj' and executing macro 'a' used to go to the beginning
> of the line, delete the first two chars, then jump down one line.
> Now, the cursor goes to the beginning of the line and execution of
> the macro stops -- no deletions or jumping down one line. The same
> when using '^' or '$'. Leaving out the movement to the beginning or
> end of the line results in the expected behavior: the macro is
> executed completely. What gives?

A few things occur to me:

1) are you doing this in a stock vim? Or do you have some
plugin/mapping that might be interfering? I just tried it here and
it worked fine. Can you replicate within

$ vim -u NONE

2) are you doing it on a blank line where the first "x" would fail,
stopping the rest of the macro's execution?

3) (kinda part of #1) do you happen to have some strange mapping for
"0x" that would interfere with the playback? If you manually type

0xx

does it work for you outside a macro?

4) you are executing this in Normal mode, not some other mode, right?

-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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201225074357.75fa192a%40bigbox.attlocal.net.

Thursday, December 24, 2020

Re: Substitute pattern over multiple lines



On Thursday, 24 December 2020 at 16:01:35 UTC-4 stevelitt wrote:
On Wed, 23 Dec 2020 21:16:20 -0400
John Cordes <john....@dal.ca> wrote:


> One big problem with the first part is that I *only* want to
> concatenate the continuation lines when they appear immediately
> following a "2 NOTE..." tag, AND that "2 NOTE" tag must be either the
> next or next but one line after "2 TYPE tngnote".
>
> I neglected to make it clear earlier that I need to first search on
> "2 TYPE tngnote" since there are other "2 TYPE" tags where I don't
> want to change anything.

Personally I'd do this as an AWK program (not an AWK one-liner). Have a
variable that gets incremented once when you hit "2 NOTE tngnote", gets
incremented again when you hit a "2 NOTE" 1 or 2 lines below, and
incremented again when you hit "3 CONC". If you increment twice like
this, you remove the "3 CONC" from the beginning of the each "3 CONC"
line and output it. At the end of the continuations, you put a </div>.
This requires that you put the corresponding <div> just before you
output the "2 NOTE" line.

If, at any time, you hit a line that forecloses the possibility of such
line-grafting, you drop the variable back to its original value.

It would also be very easy in Python, Python's advantage is that it can
easily store lines and "look back" before printing them. AWK can do
that, but it's more difficult.

I know this is offtopic on this list, but I think any Vim or ex
solution that can be made will be fragile and difficult to understand.

 Steve,

  I do understand. I am quite sure that if I had asked my son for help with this we would have ended up with an AWK script. That has happened before for at least one vaguely similar sort of job (in the sense of storing lines and checking back). I just really like using Vim, even though my skills for the more advanced techniques are sadly lacking.
 I have intended for ages to learn Python (I know that it is generally said to be very easy to learn) but it hasn't happened - not sure it ever will.
 
 John

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/ffbfce0c-725c-4794-8ae9-f60330de51d4n%40googlegroups.com.

Re: Substitute pattern over multiple lines

On 2020-12-24 14:43, Steve Litt wrote:
> On Wed, 23 Dec 2020 17:08:32 -0600
> Tim Chase <vim@tim.thechases.com> wrote:
>> 2 NOTE \zs
>>
>> This does join *all* the lines and doesn't re-wrap them, so you'd
>> then want a second pass to do the wrapping
>>
>> :set tw=70
>> :g/<div [^>]*>.*<\/div>$/norm gqq
>
> His destination is HTML so he doesn't need to wrap them: The browser
> will wrap them for him.

However he also wrote

"""
I want to surround the text of the NOTE with a 'div' tag, so that
the final result should look like this:

=======================
1 EVEN
2 TYPE tngnote
2 NOTE <div class="xxx">I have included the children William,
Charles, Alice, and with his parents in 1881, and with his widowed
mother in 1891 (e.g. see my online transcription of the 1891
Smiths with James Moser, son of Henry Moser and Mary Henneberry,
and his wife Margaret Woodin; however, I have not yet taken this
step.</div>
1 BIRT
=======================
"""

which included the wrapping (even if the HTML rendering engine would
do that for him) in the example desired output, so I included the
fairly straight-forward means by which one could do that if needed.

-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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201224143527.693a87df%40bigbox.attlocal.net.

Re: Substitute pattern over multiple lines



On Thu, Dec 24, 2020 at 3:43 PM Steve Litt <slitt@troubleshooters.com> wrote:
On Wed, 23 Dec 2020 17:08:32 -0600
Tim Chase <vim@tim.thechases.com> wrote:


>   2 NOTE \zs
>
> This does join *all* the lines and doesn't re-wrap them, so you'd
> then want a second pass to do the wrapping
>
>   :set tw=70
>   :g/<div [^>]*>.*<\/div>$/norm gqq

His destination is HTML so he doesn't need to wrap them: The browser
will wrap them for him.

  Correct.  Clearly Tim's initial response was intended to deal with the precise format I said I wanted the output to be in.

 Things are working very well now thanks to the excellent help from Tim.

 John Cordes 

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAGZBEdQdqN-J_usNw0kaHuWRfr_97xO0CcfEfr%3DpryLE_uPCNQ%40mail.gmail.com.

Re: Substitute pattern over multiple lines

On Wed, 23 Dec 2020 21:16:20 -0400
John Cordes <john.cordes@dal.ca> wrote:


> One big problem with the first part is that I *only* want to
> concatenate the continuation lines when they appear immediately
> following a "2 NOTE..." tag, AND that "2 NOTE" tag must be either the
> next or next but one line after "2 TYPE tngnote".
>
> I neglected to make it clear earlier that I need to first search on
> "2 TYPE tngnote" since there are other "2 TYPE" tags where I don't
> want to change anything.

Personally I'd do this as an AWK program (not an AWK one-liner). Have a
variable that gets incremented once when you hit "2 NOTE tngnote", gets
incremented again when you hit a "2 NOTE" 1 or 2 lines below, and
incremented again when you hit "3 CONC". If you increment twice like
this, you remove the "3 CONC" from the beginning of the each "3 CONC"
line and output it. At the end of the continuations, you put a </div>.
This requires that you put the corresponding <div> just before you
output the "2 NOTE" line.

If, at any time, you hit a line that forecloses the possibility of such
line-grafting, you drop the variable back to its original value.

It would also be very easy in Python, Python's advantage is that it can
easily store lines and "look back" before printing them. AWK can do
that, but it's more difficult.

I know this is offtopic on this list, but I think any Vim or ex
solution that can be made will be fragile and difficult to understand.

SteveT

Steve Litt
Autumn 2020 featured book: Thriving in Tough Times
http://www.troubleshooters.com/thrive

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201224150120.72235c5f%40mydesk.domain.cxm.

Re: Substitute pattern over multiple lines

On Wed, 23 Dec 2020 17:08:32 -0600
Tim Chase <vim@tim.thechases.com> wrote:


> 2 NOTE \zs
>
> This does join *all* the lines and doesn't re-wrap them, so you'd
> then want a second pass to do the wrapping
>
> :set tw=70
> :g/<div [^>]*>.*<\/div>$/norm gqq

His destination is HTML so he doesn't need to wrap them: The browser
will wrap them for him.

SteveT

Steve Litt
Autumn 2020 featured book: Thriving in Tough Times
http://www.troubleshooters.com/thrive

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201224144324.41cb95a0%40mydesk.domain.cxm.

Re: Substitute pattern over multiple lines

On Wed, Dec 23, 2020 at 10:52:43PM -0600, Tim Chase wrote:
> On 2020-12-23 22:34, John Cordes wrote:
> > :g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs\(.*\n\(\%(\D\|3 CONC
> > \).*\n\)\+\)/\='<div
> > class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
> > 'g'), '\n', '', 'g')."<\/div>\n"
> >
> > which as far as I can tell at the moment is working perfectly,
> > handling all situations the way I wanted.
>
> The only glaring edge-case is a situation in which a "2 TYPE tngnote"
> section is followed by *no* NOTE, followed by a section that *isn't*
> a "2 TYPE tngnote" that *does* have a NOTE that shouldn't be touched
> such as
>
> 2 TYPE tngnote
> 9 TIM FAKE ANNOTATION this tngnote has no NOTE
> 2 TYPE granola
> 2 NOTE Don't touch granola-type notes or
> 3 CONC rewrap their content or add <div>s!
>
> In such a case, it will wrap the NOTE even though it's in a different
> TYPE that shouldn't be touched because it's the first NOTE after a "2
> TYPE tngnote", even though it's in a different section.
>
> So that's where I'd focus my checking :-)
>
> -tim

Thanks Tim. The GEDCOM file, exported from my desktop genealogy
program TMG, *shouldn't* have a case like that (a tngnote tag
which isn't followed by its own Note), but... Hey, it's produced
by a large, complex, software program which is no longer supported
and does have a few known bugs. So obviously one can never
guarantee what will actually happen in practice.

I will certainly keep a lookout for this edge case -- it would
indeed lead to very undesirable results. Presumably I should be
able to do a search for two successive "2 TYPE tngnote" entries
which don't have an intervening "2 NOTE " tag. Not sure how, but
I'll give it a try. :-)

Thanks for the heads-up on this,
John

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201224145741.GB30109%40dal.ca.

Wednesday, December 23, 2020

Re: Substitute pattern over multiple lines

On 2020-12-23 22:34, John Cordes wrote:
> :g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs\(.*\n\(\%(\D\|3 CONC
> \).*\n\)\+\)/\='<div
> class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
> 'g'), '\n', '', 'g')."<\/div>\n"
>
> which as far as I can tell at the moment is working perfectly,
> handling all situations the way I wanted.

The only glaring edge-case is a situation in which a "2 TYPE tngnote"
section is followed by *no* NOTE, followed by a section that *isn't*
a "2 TYPE tngnote" that *does* have a NOTE that shouldn't be touched
such as

2 TYPE tngnote
9 TIM FAKE ANNOTATION this tngnote has no NOTE
2 TYPE granola
2 NOTE Don't touch granola-type notes or
3 CONC rewrap their content or add <div>s!

In such a case, it will wrap the NOTE even though it's in a different
TYPE that shouldn't be touched because it's the first NOTE after a "2
TYPE tngnote", even though it's in a different section.

So that's where I'd focus my checking :-)

-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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201223225243.40882090%40bigbox.attlocal.net.

Re: Substitute pattern over multiple lines



On Wed, Dec 23, 2020 at 11:57 PM Tim Chase <vim@tim.thechases.com> wrote:
On 2020-12-23 23:18, John Cordes wrote:
>> :g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs\(.*\n\(\%(\D\|3 CONC
>> \).*\n\)\+\)/\='<div
>> class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
>> 'g'), '\n', '', 'g')."<\/div>\n"
>
>  The last ":g..." command I listed above is working correctly
> when there are continuation lines (i.e. at least one "3 CONC" tag
> following the "2 NOTE" tag, but I think it seems to be skipping by
> the "2 NOTE" tags which do *not* have a CONC / Continuation tag.

Ah, while I'm not positive (so shooting from the hip here) I think you
want to change the

  \+

(one or more continuation lines) to just

  *

(zero or more continuation lines) to produce

:g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs\(.*\n\%(\%(\D\|3 CONC
\).*\n\)\+\)/\='<div class="xxx">'.substitute(substitute(submatch(1),
'\n3 CONC ', '', 'g'), '\n', '', 'g')."<\/div>\n"

(I also snuck in an extra "%" in the inner \(…\) which I missed when
transcribing it earlier, but shouldn't impact the results)

-tim

 

 I think that did it - on a quick check.
I had tried changing that "\+" to "\=" thinking that would allow for 0 or 1 but something went wrong - can't remember exactly what right now. I should have just tried * - can't think why I didn't.

 Thanks again!
 John


  

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAGZBEdShfP_x%3DKDQB2Gd3Yg%3DDkeBTXCSF5xWw7ZoJ%3DTgYs3_Xg%40mail.gmail.com.

Re: Substitute pattern over multiple lines

On 2020-12-23 23:18, John Cordes wrote:
>> :g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs\(.*\n\(\%(\D\|3 CONC
>> \).*\n\)\+\)/\='<div
>> class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
>> 'g'), '\n', '', 'g')."<\/div>\n"
>
> The last ":g..." command I listed above is working correctly
> when there are continuation lines (i.e. at least one "3 CONC" tag
> following the "2 NOTE" tag, but I think it seems to be skipping by
> the "2 NOTE" tags which do *not* have a CONC / Continuation tag.

Ah, while I'm not positive (so shooting from the hip here) I think you
want to change the

\+

(one or more continuation lines) to just

*

(zero or more continuation lines) to produce

:g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs\(.*\n\%(\%(\D\|3 CONC
\).*\n\)\+\)/\='<div class="xxx">'.substitute(substitute(submatch(1),
'\n3 CONC ', '', 'g'), '\n', '', 'g')."<\/div>\n"

(I also snuck in an extra "%" in the inner \(…\) which I missed when
transcribing it earlier, but shouldn't impact the results)

-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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201223215706.6f09714c%40bigbox.attlocal.net.

Re: Substitute pattern over multiple lines

On Wed, Dec 23, 2020 at 10:34:38PM -0400, John Cordes wrote:
> On Wed, Dec 23, 2020 at 10:07:26PM -0400, John Cordes wrote:
> >
> > On Wed, Dec 23, 2020 at 9:31 PM Tim Chase <vim@tim.thechases.com> wrote:
> >
> > On 2020-12-23 20:39, John Cordes wrote:
> > >> I'd start with this ugly monstrosity:
> > >>
> > >> :%s/^2 \u\{3,} \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div
> > >> class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
> > >> 'g'), '\n', '', 'g')."<\/div>\n"
>
> > :g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs…
> >
> > Hope this helps get you on the right path,
> >
> > -tim
> >
> > This is amazing looking, Tim -- thanks so much! There is a lot for a nearly
> > 80-year old to unpack here -- it's going to take me a while. :)
> > It looks as though you have covered all the bases I want to deal with.
> >
> > Thank you again,
> > John
>
> Just a quick report to say that following your suggestion above leads to:
>
> :g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '', 'g'), '\n', '', 'g')."<\/div>\n"
>
> which as far as I can tell at the moment is working perfectly,
> handling all situations the way I wanted. I will check further and
> also test on another GEDCOM file when I'm fresher.
>
> Thanks again Tim; I have learned a lot. Now if it would only stick...
>
> John

Tim,

I hate to trouble you further about this, but possibly while it
is still reasonably fresh in your mind...

The last ":g..." command I listed above is working correctly
when there are continuation lines (i.e. at least one "3 CONC" tag
following the "2 NOTE" tag, but I think it seems to be skipping by
the "2 NOTE" tags which do *not* have a CONC / Continuation tag.
I thought the pattern would be allowing for no CONC tags but I'm
not seeing what is wrong.
At least I *think* that's what I am seeing.

John



--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201224031837.GA30109%40dal.ca.

Re: Substitute pattern over multiple lines

On Wed, Dec 23, 2020 at 10:07:26PM -0400, John Cordes wrote:
>
> On Wed, Dec 23, 2020 at 9:31 PM Tim Chase <vim@tim.thechases.com> wrote:
>
> On 2020-12-23 20:39, John Cordes wrote:
> >> I'd start with this ugly monstrosity:
> >>
> >> :%s/^2 \u\{3,} \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div
> >> class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
> >> 'g'), '\n', '', 'g')."<\/div>\n"

> :g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs…
>
> Hope this helps get you on the right path,
>
> -tim
>
> This is amazing looking, Tim -- thanks so much! There is a lot for a nearly
> 80-year old to unpack here -- it's going to take me a while. :)
> It looks as though you have covered all the bases I want to deal with.
>
> Thank you again,
> John

Just a quick report to say that following your suggestion above leads to:

:g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '', 'g'), '\n', '', 'g')."<\/div>\n"

which as far as I can tell at the moment is working perfectly,
handling all situations the way I wanted. I will check further and
also test on another GEDCOM file when I'm fresher.

Thanks again Tim; I have learned a lot. Now if it would only stick...

John

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201224023438.GA19170%40dal.ca.

Re: Substitute pattern over multiple lines


On Wed, Dec 23, 2020 at 9:31 PM Tim Chase <vim@tim.thechases.com> wrote:
On 2020-12-23 20:39, John Cordes wrote:
>> I'd start with this ugly monstrosity:
>>
>> :%s/^2 \u\{3,} \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div 
>> class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
>> 'g'), '\n', '', 'g')."<\/div>\n"
>
>  I will attempt to deconstruct your 'monstrosity' somewhat later,

Tweaking it so that it only does NOTE items, not generic
continuations:

:%s/^2 NOTE \zs\(.*\n\%(\%(\D\|3 CONC \).*\n\)\+\)/\='<div
class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '', 
'g'), '\n', '', 'g')."<\/div>\n"

Breaking it down so hopefully you can swap parts as you see fit:

:%s/^2 NOTE \zs     On every line starting with "2 NOTE "
                    start our replacement here (\zs)
\(                  start capturing the note
                    this will be submatch(1) later
.*                  everything else on that line
\n                  and the newline
\%(                 a non-capturing group for another line that
\%(\D               starts with either a non-digit
\|                  or
3 CONC              a literal "3 CONC "
\)                  (end of this OR of things marking a continuation)
.*\n                followed by the rest of the line
\)                  (end of this continuation-line)
\+                  we can have 1 or more continuation lines
\)                  end the capturing
/                   replace it with
\=                  the result of evaluating this expression
'<div class="xxx">' the literal opening tag
.                   and then the results of
substitute(         remove all the newlines from the results of
 substitute(        removing from
  submatch(1),      the whole set of continuation stuff
  '\n3 CONC ',      the literal newline-followed-by-"3 CONC "
  '',               and replace them with nothing
  'g'               everywhere
  ),                and in that "\n3 CONC "-less text, replace
 '\n',              newlines with
 '',                nothing
 'g')               everywhere
.                   and then tack on
"<\/div>\n"         the literal closing </div> followed by a newline

>  It's a bit more complicated than I first explained. Two aspects:
> a) I *do* need to search on the "2 NOTE" lines, since there are
> various other chunks of lines with the CONC lines; and
> b) Sometimes the line "2 TYPE tngnote" has a line between it and
> the "2 NOTE". The intervening line can look like this
>
> 2 DATE 18 AUG 1776
>  or this
> 2 _SDATE 1802

Given the substitution command above, it should only touch "2 NOTE"
lines with subsequent "3 CONT" lines.  It does *every* "2 NOTE" so if
you need to limit them to just those that immediately follow "2 TYPE
tngnote" (assuming there aren't any "2 TYPE tngnote" that *don't*
have a NOTE immediately following them), you can tweak that command,
changing that inital "%" to

:g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs…

This looks for all the "2 TYPE tngnote" lines, searches forward
(skipping over any DATE/_SDATE lines or other intervening stuff) for
the "2 NOTE " line following it, and then only performs the
subsitution on those particular lines.

>  So the lines to change could look like this:
>
> ===================
> 1 EVEN
> 2 TYPE tngnote
> 2 _SDATE 1802
> 2 NOTE The surname of John's wife is not positively established.
> However, it is certain that her given name is Elizabeth; evidence
> for this comes first from the baptismal records for Rebecca and
> Eliza Catherine; these children were born while th
> 3 CONC e family was in London so the records are available in the
> London Metropolitan Archives (the other two children were born in
> Sheffield). Henry's baptismal record in Sheffield also has his
> parents being John (a skinner) and Elizabeth. The id
> 3 CONC entification of John's wife specifically with  Elizabeth
> Coxsey is somewhat tentative, however.
> 1 EVEN
> ===================
>
>  This search pattern
> /^2 TYPE tngnote.*\n*\(\_^2 .*DATE.*\)*\n\_^2 NOTE
>
>  works to find all 3 possibilities: no DATE line, an _SDATE line
> or a DATE line.
>
>  I thought I would be able to combine that with your pattern like
> so:
>
> :%s/^2 TYPE tngnote.*\n*\(\_^2 .*DATE.*\)*\n\_^2 NOTE
> \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div
> class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
> 'g'), '\n', '', 'g')."<\/div>\n"
>
>  but that is not working.

I suspect that the problem snuck in by using \(…\) in your added
conditions which captured that as submatch(1).  So you can either
make it non-capturing by adding that "%" before the open-paren:

  \%(\_^2 .*DATE.*\)

or change the "submatch(1)" to "submatch(2)"

> Here's an example of one small chunk of
> lines which were transformed by that command:
>
> 1 EVEN
> 2 TYPE tngnote
> 2 DATE 18 AUG 1776
> 2 NOTE <div class="xxx">2 DATE 18 AUG 1776</div>
> 1 EVEN

Note that the content here is what you captured in the first group.
:-)

Hope this helps get you on the right path,

-tim

 
 This is amazing looking, Tim -- thanks so much! There is a lot for a nearly 80-year old to unpack here -- it's going to take me a while. :)
  It looks as though you have covered all the bases I want to deal with. 

 Thank you again,
 John
    

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAGZBEdSChuJr8t82%3DOE-aMwQ6GgXyUKj-6SnBMmpQJLEHC9h%2BA%40mail.gmail.com.

Re: Substitute pattern over multiple lines

On 2020-12-23 20:39, John Cordes wrote:
>> I'd start with this ugly monstrosity:
>>
>> :%s/^2 \u\{3,} \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div
>> class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
>> 'g'), '\n', '', 'g')."<\/div>\n"
>
> I will attempt to deconstruct your 'monstrosity' somewhat later,

Tweaking it so that it only does NOTE items, not generic
continuations:

:%s/^2 NOTE \zs\(.*\n\%(\%(\D\|3 CONC \).*\n\)\+\)/\='<div
class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
'g'), '\n', '', 'g')."<\/div>\n"

Breaking it down so hopefully you can swap parts as you see fit:

:%s/^2 NOTE \zs On every line starting with "2 NOTE "
start our replacement here (\zs)
\( start capturing the note
this will be submatch(1) later
.* everything else on that line
\n and the newline
\%( a non-capturing group for another line that
\%(\D starts with either a non-digit
\| or
3 CONC a literal "3 CONC "
\) (end of this OR of things marking a continuation)
.*\n followed by the rest of the line
\) (end of this continuation-line)
\+ we can have 1 or more continuation lines
\) end the capturing
/ replace it with
\= the result of evaluating this expression
'<div class="xxx">' the literal opening tag
. and then the results of
substitute( remove all the newlines from the results of
substitute( removing from
submatch(1), the whole set of continuation stuff
'\n3 CONC ', the literal newline-followed-by-"3 CONC "
'', and replace them with nothing
'g' everywhere
), and in that "\n3 CONC "-less text, replace
'\n', newlines with
'', nothing
'g') everywhere
. and then tack on
"<\/div>\n" the literal closing </div> followed by a newline

> It's a bit more complicated than I first explained. Two aspects:
> a) I *do* need to search on the "2 NOTE" lines, since there are
> various other chunks of lines with the CONC lines; and
> b) Sometimes the line "2 TYPE tngnote" has a line between it and
> the "2 NOTE". The intervening line can look like this
>
> 2 DATE 18 AUG 1776
> or this
> 2 _SDATE 1802

Given the substitution command above, it should only touch "2 NOTE"
lines with subsequent "3 CONT" lines. It does *every* "2 NOTE" so if
you need to limit them to just those that immediately follow "2 TYPE
tngnote" (assuming there aren't any "2 TYPE tngnote" that *don't*
have a NOTE immediately following them), you can tweak that command,
changing that inital "%" to

:g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs…

This looks for all the "2 TYPE tngnote" lines, searches forward
(skipping over any DATE/_SDATE lines or other intervening stuff) for
the "2 NOTE " line following it, and then only performs the
subsitution on those particular lines.

> So the lines to change could look like this:
>
> ===================
> 1 EVEN
> 2 TYPE tngnote
> 2 _SDATE 1802
> 2 NOTE The surname of John's wife is not positively established.
> However, it is certain that her given name is Elizabeth; evidence
> for this comes first from the baptismal records for Rebecca and
> Eliza Catherine; these children were born while th
> 3 CONC e family was in London so the records are available in the
> London Metropolitan Archives (the other two children were born in
> Sheffield). Henry's baptismal record in Sheffield also has his
> parents being John (a skinner) and Elizabeth. The id
> 3 CONC entification of John's wife specifically with Elizabeth
> Coxsey is somewhat tentative, however.
> 1 EVEN
> ===================
>
> This search pattern
> /^2 TYPE tngnote.*\n*\(\_^2 .*DATE.*\)*\n\_^2 NOTE
>
> works to find all 3 possibilities: no DATE line, an _SDATE line
> or a DATE line.
>
> I thought I would be able to combine that with your pattern like
> so:
>
> :%s/^2 TYPE tngnote.*\n*\(\_^2 .*DATE.*\)*\n\_^2 NOTE
> \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div
> class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
> 'g'), '\n', '', 'g')."<\/div>\n"
>
> but that is not working.

I suspect that the problem snuck in by using \(…\) in your added
conditions which captured that as submatch(1). So you can either
make it non-capturing by adding that "%" before the open-paren:

\%(\_^2 .*DATE.*\)

or change the "submatch(1)" to "submatch(2)"

> Here's an example of one small chunk of
> lines which were transformed by that command:
>
> 1 EVEN
> 2 TYPE tngnote
> 2 DATE 18 AUG 1776
> 2 NOTE <div class="xxx">2 DATE 18 AUG 1776</div>
> 1 EVEN

Note that the content here is what you captured in the first group.
:-)

Hope this helps get you on the right path,

-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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201223193113.36cd777d%40bigbox.attlocal.net.

Re: Substitute pattern over multiple lines


On Wed, Dec 23, 2020 at 9:04 PM George Dinwiddie <lists@idiacomputing.com> wrote:
Why not use

:%s/\n3 CONC //

to concatenate all the continuations and then use

:%s/\(2 NOTE \)\(.*\)/\1<div> class="xxx">\2<\/div>/

to turn all the NOTE lines into <div> blocks? Or am I misunderstanding
something about the transformation you need?

  - George

 One big problem with the first part is that I *only* want to concatenate the continuation lines when they appear immediately following a "2 NOTE..." tag, AND that "2 NOTE" tag must be either the next or next but one line after "2 TYPE tngnote". 
 
 I neglected to make it clear earlier that I need to first search on  "2 TYPE tngnote" since there are other "2 TYPE" tags where I don't want to change anything.

 John 

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAGZBEdQR%2B2FtPG%3D%2B%3DNUWtDXCwgAXgBK764J-71VdKj_1tJ-imQ%40mail.gmail.com.

Re: Substitute pattern over multiple lines

Why not use

:%s/\n3 CONC //

to concatenate all the continuations and then use

:%s/\(2 NOTE \)\(.*\)/\1<div> class="xxx">\2<\/div>/

to turn all the NOTE lines into <div> blocks? Or am I misunderstanding
something about the transformation you need?

- George

On 12/23/20 6:08 PM, Tim Chase wrote:
> On 2020-12-23 17:48, John Cordes wrote:
>> I'm seeking help with editing a GEDCOM (genealogy) file. For
>> this I'm using Vim 8.2 in Windows. Here is a segment of text from
>> the file (the language doesn't make sense since I've deleted
>> some internal lines in the NOTEs which aren't relevant to the
>> question):
>>
>> =======================
>> 1 EVEN
>> 2 TYPE tngnote
>> 2 NOTE I have included the children William, Charles, Alice, and
>> with his parents in 1881, and with his widowed mother in 1
>> 3 CONC 891 (e.g. see my online transcription of the 1891 Smiths
>> with James Moser, son of Henry Moser and Mary Henneberry, and his
>> wife Margaret Woodin; however
>> 3 CONC , I have not yet taken this step.
>> 1 BIRT
>> =======================
>>
>> The 2 lines beginning with ^3 CONC are Continuation
>> (CONC=Concatenation) lines.
>>
>> I want to surround the text of the NOTE with a 'div' tag, so that
>> the final result should look like this:
>>
>> =======================
>> 1 EVEN
>> 2 TYPE tngnote
>> 2 NOTE <div class="xxx">I have included the children William,
>> Charles, Alice, and with his parents in 1881, and with his widowed
>> mother in 1891 (e.g. see my online transcription of the 1891
>> Smiths with James Moser, son of Henry Moser and Mary Henneberry,
>> and his wife Margaret Woodin; however, I have not yet taken this
>> step.</div>
>> 1 BIRT
>> =======================
>
> I'd start with this ugly monstrosity:
>
> :%s/^2 \u\{3,} \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div
> class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
> 'g'), '\n', '', 'g')."<\/div>\n"
>
> (all one line in case it breaks in the mail)
>
> If you only want it to do "2 NOTE" lines, you can change that initial
>
> 2 \u\{3,} \zs
>
> (which does any item that has continuations) to
>
> 2 NOTE \zs
>
> This does join *all* the lines and doesn't re-wrap them, so you'd
> then want a second pass to do the wrapping
>
> :set tw=70
> :g/<div [^>]*>.*<\/div>$/norm gqq
>
> Hope this gives you some ideas to work with.
>
> -tim
>
>
>

--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach https://pragprog.com/titles/gdestimate/
----------------------------------------------------------------------

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/c69245fc-7e67-f39d-5eb4-587a4d272108%40iDIAcomputing.com.

Re: Substitute pattern over multiple lines

On Wed, Dec 23, 2020 at 05:08:32PM -0600, Tim Chase wrote:
> On 2020-12-23 17:48, John Cordes wrote:
> > I'm seeking help with editing a GEDCOM (genealogy) file. For
> > this I'm using Vim 8.2 in Windows. Here is a segment of text from
> > the file (the language doesn't make sense since I've deleted
> > some internal lines in the NOTEs which aren't relevant to the
> > question):
> >
> > =======================
> > 1 EVEN
> > 2 TYPE tngnote
> > 2 NOTE I have included the children William, Charles, Alice, and
> > with his parents in 1881, and with his widowed mother in 1
> > 3 CONC 891 (e.g. see my online transcription of the 1891 Smiths
> > with James Moser, son of Henry Moser and Mary Henneberry, and his
> > wife Margaret Woodin; however
> > 3 CONC , I have not yet taken this step.
> > 1 BIRT
> > =======================
> >
> > The 2 lines beginning with ^3 CONC are Continuation
> > (CONC=Concatenation) lines.
> >
> > I want to surround the text of the NOTE with a 'div' tag, so that
> > the final result should look like this:
> >
> > =======================
> > 1 EVEN
> > 2 TYPE tngnote
> > 2 NOTE <div class="xxx">I have included the children William,
> > Charles, Alice, and with his parents in 1881, and with his widowed
> > mother in 1891 (e.g. see my online transcription of the 1891
> > Smiths with James Moser, son of Henry Moser and Mary Henneberry,
> > and his wife Margaret Woodin; however, I have not yet taken this
> > step.</div>
> > 1 BIRT
> > =======================
>
> I'd start with this ugly monstrosity:
>
> :%s/^2 \u\{3,} \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div
> class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
> 'g'), '\n', '', 'g')."<\/div>\n"
>
> (all one line in case it breaks in the mail)
>
> If you only want it to do "2 NOTE" lines, you can change that initial
>
> 2 \u\{3,} \zs
>
> (which does any item that has continuations) to
>
> 2 NOTE \zs
>
> This does join *all* the lines and doesn't re-wrap them, so you'd
> then want a second pass to do the wrapping
>
> :set tw=70
> :g/<div [^>]*>.*<\/div>$/norm gqq
>
> Hope this gives you some ideas to work with.

Yes indeed Tim -- an excellent idea. Thanks very much.
I will attempt to deconstruct your 'monstrosity' somewhat later,
but I've been trying to get things to work with my situation.

It's a bit more complicated than I first explained. Two aspects:
a) I *do* need to search on the "2 NOTE" lines, since there are
various other chunks of lines with the CONC lines; and
b) Sometimes the line "2 TYPE tngnote" has a line between it and
the "2 NOTE". The intervening line can look like this

2 DATE 18 AUG 1776
or this
2 _SDATE 1802

So the lines to change could look like this:

===================
1 EVEN
2 TYPE tngnote
2 _SDATE 1802
2 NOTE The surname of John's wife is not positively established.
However, it is certain that her given name is Elizabeth; evidence
for this comes first from the baptismal records for Rebecca and
Eliza Catherine; these children were born while th
3 CONC e family was in London so the records are available in the
London Metropolitan Archives (the other two children were born in
Sheffield). Henry's baptismal record in Sheffield also has his
parents being John (a skinner) and Elizabeth. The id
3 CONC entification of John's wife specifically with Elizabeth
Coxsey is somewhat tentative, however.
1 EVEN
===================

This search pattern
/^2 TYPE tngnote.*\n*\(\_^2 .*DATE.*\)*\n\_^2 NOTE

works to find all 3 possibilities: no DATE line, an _SDATE line
or a DATE line.

I thought I would be able to combine that with your pattern like so:

:%s/^2 TYPE tngnote.*\n*\(\_^2 .*DATE.*\)*\n\_^2 NOTE \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '', 'g'), '\n', '', 'g')."<\/div>\n"

but that is not working. Here's an example of one small chunk of
lines which were transformed by that command:

1 EVEN
2 TYPE tngnote
2 DATE 18 AUG 1776
2 NOTE <div class="xxx">2 DATE 18 AUG 1776</div>
1 EVEN

The command is eliminating the content which had been in the NOTE tags altogether.

I will keep trying, but more help would be terrific!

Thanks,
John

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201224003911.GA16492%40dal.ca.

Re: Substitute pattern over multiple lines

On 2020-12-23 17:48, John Cordes wrote:
> I'm seeking help with editing a GEDCOM (genealogy) file. For
> this I'm using Vim 8.2 in Windows. Here is a segment of text from
> the file (the language doesn't make sense since I've deleted
> some internal lines in the NOTEs which aren't relevant to the
> question):
>
> =======================
> 1 EVEN
> 2 TYPE tngnote
> 2 NOTE I have included the children William, Charles, Alice, and
> with his parents in 1881, and with his widowed mother in 1
> 3 CONC 891 (e.g. see my online transcription of the 1891 Smiths
> with James Moser, son of Henry Moser and Mary Henneberry, and his
> wife Margaret Woodin; however
> 3 CONC , I have not yet taken this step.
> 1 BIRT
> =======================
>
> The 2 lines beginning with ^3 CONC are Continuation
> (CONC=Concatenation) lines.
>
> I want to surround the text of the NOTE with a 'div' tag, so that
> the final result should look like this:
>
> =======================
> 1 EVEN
> 2 TYPE tngnote
> 2 NOTE <div class="xxx">I have included the children William,
> Charles, Alice, and with his parents in 1881, and with his widowed
> mother in 1891 (e.g. see my online transcription of the 1891
> Smiths with James Moser, son of Henry Moser and Mary Henneberry,
> and his wife Margaret Woodin; however, I have not yet taken this
> step.</div>
> 1 BIRT
> =======================

I'd start with this ugly monstrosity:

:%s/^2 \u\{3,} \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div
class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
'g'), '\n', '', 'g')."<\/div>\n"

(all one line in case it breaks in the mail)

If you only want it to do "2 NOTE" lines, you can change that initial

2 \u\{3,} \zs

(which does any item that has continuations) to

2 NOTE \zs

This does join *all* the lines and doesn't re-wrap them, so you'd
then want a second pass to do the wrapping

:set tw=70
:g/<div [^>]*>.*<\/div>$/norm gqq

Hope this gives you some ideas to work with.

-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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201223170832.7ca70687%40bigbox.attlocal.net.

Substitute pattern over multiple lines

I'm seeking help with editing a GEDCOM (genealogy) file. For
this I'm using Vim 8.2 in Windows. Here is a segment of text from
the file (the language doesn't make sense since I've deleted
some internal lines in the NOTEs which aren't relevant to the
question):

=======================
1 EVEN
2 TYPE tngnote
2 NOTE I have included the children William, Charles, Alice, and
with his parents in 1881, and with his widowed mother in 1
3 CONC 891 (e.g. see my online transcription of the 1891 Smiths
with James Moser, son of Henry Moser and Mary Henneberry, and his
wife Margaret Woodin; however
3 CONC , I have not yet taken this step.
1 BIRT
=======================

The 2 lines beginning with ^3 CONC are Continuation (CONC=Concatenation) lines.

I want to surround the text of the NOTE with a 'div' tag, so that
the final result should look like this:

=======================
1 EVEN
2 TYPE tngnote
2 NOTE <div class="xxx">I have included the children William,
Charles, Alice, and with his parents in 1881, and with his widowed
mother in 1891 (e.g. see my online transcription of the 1891
Smiths with James Moser, son of Henry Moser and Mary Henneberry,
and his wife Margaret Woodin; however, I have not yet taken this
step.</div>
1 BIRT
=======================

The complete GEDCOM file (which may have 850,000 or so lines) may
have NOTE tags with 0, 1, 2, or 3 CONC tags (probably no more than
that) following.

It is this variable number of continuation lines which I find
most difficult to deal with.

For the NOTE tags where there are no continuation lines I believe
this is working:

:g/^2 TYPE tngnote/+1s/^2 NOTE\(.*\)/2 NOTE <div class="xxx">\1 <\/div>/

but when there are 1 or more CONC tags following the NOTE I get stuck.

I tried:
:g/^2 TYPE tngnote/+1s/^2 NOTE\(.*\n\(3 CONC \(.*\)\)*\)/2 NOTE <div class="xxx">\1\3<\/div> /

which 'almost' works if there is just 1 CONC tag (though it
leaves "3 CONC" in place which I don't want). So it's pretty bad!


I realize this is pretty messy looking but I'm hoping one of the
experts who so generously contribute to this group may be able to
give me a pointer for how to deal with this.

Thanks,
John Cordes


--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201223214854.GA8272%40dal.ca.

Tuesday, December 22, 2020

complex-repeat Behavior Changed Recently

Hi Vim,
Typing 'qa0xxj' and executing macro 'a' used to go to the beginning of the line, delete the first two chars, then jump down one line. Now, the cursor goes to the beginning of the line and execution of the macro stops -- no deletions or jumping down one line. The same when using '^' or '$'. Leaving out the movement to the beginning or end of the line results in the expected behavior: the macro is executed completely. What gives?


Sent with ProtonMail Secure Email.

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/o29IU9TNEg9imqCcV1JdApUiqhFIkytIM93eTf-nCfhS2aRJEskv65hg1qCOYVBMzWHey54GDYO1j3rQHsGKvImv9UQlo1ukCcpIzF5W7qI%3D%40protonmail.com.

Re: "deoplete" has a problem with my ESP32... :)

On 12/22 12:02, BPJ wrote:
> Den tis 22 dec. 2020 11:44 <tuxic@posteo.de> skrev:
>
> > Hi,
> >
> > currently I am codeing a firmware for an ESP32 microcontroller.
> > I am using the ESP-IDF framework. This framework needs some
> > environment variables to be set. If this is done, deoplete
> > get confused and behaves oddly (seems to be based on the
> > python version used by ESP-IDF...)
> >
> > Is there a way to detect
> > * the existence and the contence of an environment variable inside vim
> > script? How can I do this?
> >
>
> Accessing/manipulating environment variables is easy:
>
> echo exists('$FOO')
> let $FOO = 'bar'
> echo exists('$FOO')
> echo empty($FOO)
> echo $FOO
>
> Note that the $ is always included. It is Vim's way of distinguishing env
> variables.
> I do this all the time when running scripts which take env var config from
> inside Vim.
>
>
> * the python version which is currently in use? How can I do this?
> >
>
> > And
> > * is it possible to disable deocomplete temporarily without
> > uninstalling it ? How can I do this?
> >
> >
> > Cheers!
> > mcc
> >
> >

Hi,

thank you for your help! I found a switch to toggle deocomplete.

Cheers!
mcc

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201222121820.2xjp4bxomk3jpx5p%40solfire.