Tuesday, February 27, 2018

Just another little note of "woah, vim already does that"

I've got a rather large source file for an ETL process containing
several functions (one for each of the files it processes). There's
enough similarity between the file processing that it's easy to do a
search and end up in the wrong function without noticing.

Knowing vim supported matching/colorizing based on line-numbers, I
started out with

:match Error /\%<50l\|\%>120l/

to match anything outside the function I was focused on. But as I'd
edit, those boundaries would change. So I start grumbling, wishing
that vim supported similar functionality for marks instead of
absolute line numbers. BUT HO! It DOES!

So I dropped mark "a" at the beginning of my function, dropped mark
"b" at the end of my function, issued

:match Error /\%<'a\|\%>'b/

and lo, it updates automatically, highlighting the regions outside
the current function. And when I move to the next function, I drop
the "this is the beginning" and "this is the end" marks, and it
updates.

It continues to delight me that vim still holds new/undiscovered
tricks, even after using vim for ~18yrs now.

Anyways, thought I'd share in case it was useful for anybody else.

-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.
For more options, visit https://groups.google.com/d/optout.

No comments: