serhii.net

In the middle of the desert you can say anything you want

11 Jun 2021

Day 892

Intellij marking folders as roots

A top-level folder can be excluded, but any of the folders inside it can be marked as something else and that will override the parent! Very sensible decision actually, when I think about it

vim don’t clean clipboard buffer / + register when closing

From SO:1

autocmd VimLeave * call system("xclip -selection clipboard -i", getreg('+'))

Here vim’s system() command is interesting:

If you pass a second argument like this, Vim will write it to a temporary file and pipe it into the command on standard input.2

In any case, I should really write some alias to be able to use xclip and friends by passing parameters to them, not piping stuff - makes any kind of scripting with them much harder.

And to finish, Learn Vimscript the Hard Way seems to be still an excellent introduction to vim itself, even without the scripting part.

ag/grep output only capturing groups

This3 describes how to get ag to output not the match, but only a specific capturing group inside it:

ag -o 'https://\K.*?(?=")'

It uses PCRE features to remove stuff from before and from after the match:

  • \K resets the match start
  • (?=") sets the end to " - here, " is what should be after the match, but will not be included in it.

PCRE

Related is Learn PCRE in Y Minutes. PC in PCRE stands for “Perl Compatible”.

PCRE can be enabled in grep by doing grep -P, and it’s the default in ag.

Nel mezzo del deserto posso dire tutto quello che voglio.