:: home : bio : blog : art
My copy of Alexej Von Jawlensky "Girl with Red Ribbon", oil, 2024 (detail)
August
Sun Mon Tue Wed Thu Fri Sat
   
29    

Contact


 

Archives

Recent Posts

Tue, 29 Aug 2023
What I've Learnt Lately: WILL
# 16:14 in ./tech

I love tinkering around with the computer and digging into some of the aspects of running Linux, or the more interesting applications it can host. Take the editor Vim. Not a text editor for the masses (to say the least) but it does have an extremely broad and deep set of features and also a whole swathe of settings for them. I've not done much painting recently and have spent some time sorting out my computing experience. For this, I've learnt quite a few new things and it's made me remember how pleasurable learning stuff is.

So : What I have learnt lately a.k.a. WILL. Maybe I will try and document some of these things, if only for my own reference later.

Vim Lookaround

Viewing some old server backup logs (something else I've been "fixing"), I wanted to jump to the next line not starting with a word ("deleting").

I use the Vim text editor and to find a line that starts with a string, use the "^" regex anchor. Press "/" and :

/\v^deleting<cr>

The "<cr>" means press the return/enter key. So "^deleting" matches the word deleting at the start of a line.

The "/v" means interpret the pattern used as "very magic", so no need to quote brackets etc. See vimdoc for an explanation.

Now for the good stuff (and new to me) : to find a line not starting with "deleting", press "/" and :

/\v^(deleting)@!<cr>

This is similar to before but we wrap the pattern in brackets and end with "@!". The "@!" is a negative lookaround (i.e. "lookbehind") i.e. looks for no matching pattern behind us. The "^" means "at start of line" (behind us).

To help retain a piece of knowledge, it's usually useful to write it down somewhere.

Reference :


© Alastair Sherringham 2023
Powered by Blosxom.
Still going after all these years.