Matching a non-match

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Matching a non-match

A. Wik
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CALPW7mTGyksn-tcK2zR-%3DjNcWv3rLVXBJrO2hLhgsHu4jX4Z6w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Matching a non-match - workaround: less

Sven Guckes-3
* A. Wik <[hidden email]> [2020-12-20 14:39]:
> 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\)\@<!.*

workaround:
open the file with "less" and right after initiating search with '/'
type '!' and the prompt will switch to "Non-match /". now enter
eg "spool.exim.input" and less will skip all those lines. :-)
that's one of the features i dearly miss with vim.  oh, well.

Sven

--
LESS 563   | https://github.com/gwsw/less.git
SEARCHING: | http://www.greenwoodsoftware.com/less/
A search pattern may begin with one or more of:
^N or !  Search for NON-matching lines.
^E or *  Search multiple files (pass thru END OF FILE).
^F or @  Start search at FIRST file (for /) or last file (for ?).
^K       Highlight matches, but don't move (KEEP position).
^R       Don't use REGULAR EXPRESSIONS.

--
--
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/20201220135346.3r6h3qq4ygqn6kvs%40guckes.net.

signature.asc (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Matching a non-match

Charles Campbell-2
In reply to this post by A. Wik
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\)\@<!.*
>
Hello:

You could use LogiPat: :LP !"exim/input" and find the next line. Or, you
could use :LPE !"exim/input" and be given the expresson LogiPat used.
LogiPat comes with vim, by the way.

Regards,
Chip Campbell

--
--
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/e977745d-17e9-87ab-e057-992e622be1e7%40drchip.org.
Reply | Threaded
Open this post in threaded view
|

Re: Matching a non-match - workaround: less

Tim Chase
In reply to this post by Sven Guckes-3
On 2020-12-20 14:53, Sven Guckes wrote:
> workaround:
> open the file with "less" and right after initiating search with '/'
> type '!' and the prompt will switch to "Non-match /". now enter
> eg "spool.exim.input" and less will skip all those lines. :-)
> that's one of the features i dearly miss with vim.  oh, well.

If you've not stumbled across it, check out the "&" (and in this case
"&!") in less.  It's like a grep/filter for the buffer in less(1).

-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/20201220112141.2f965eb0%40bigbox.attlocal.net.
Reply | Threaded
Open this post in threaded view
|

Re: Matching a non-match - workaround: less

Christian Brabandt
In reply to this post by Sven Guckes-3

On So, 20 Dez 2020, Sven Guckes wrote:

> workaround:
> open the file with "less" and right after initiating search with '/'
> type '!' and the prompt will switch to "Non-match /". now enter
> eg "spool.exim.input" and less will skip all those lines. :-)
> that's one of the features i dearly miss with vim.  oh, well.

Depending on what you want, you can use `:v`

Best,
Christian
--
Wie man sein Kind nicht nennen sollte:
  Ray Genschirm

--
--
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/20201220172608.GT22416%40256bit.org.
Reply | Threaded
Open this post in threaded view
|

Re: Matching a non-match

Tim Chase
In reply to this post by A. Wik
On 2020-12-20 11:09, A. Wik wrote:
> 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\)\@<!.*

you can use which only finds the start of the line:

   /^\%(.*exim.input\)\@!

or if you want to match the entire line, you can use:

  /^\%(\%(exim.input\)\@!.\)*$/

That breaks down to

  ^          from the start of the line
  \%(…\)*    zero or more of these things
   \%(exim.match\)\@!   at each of these places, this can't match
   .                    accept a character here
  $          all the way to the end of the line
             (no partial line matches, or it would find
             ".spool/exim/inpu" (because "exim.input" doesn't yet
             match)

-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/20201220113045.1c3bafc6%40bigbox.attlocal.net.
Reply | Threaded
Open this post in threaded view
|

Re: Matching a non-match

Kenny Stauffer
In reply to this post by A. Wik
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/47986bcd-3a6e-4849-bbff-1f92366d7c8an%40googlegroups.com.