mercredi 6 mai 2015

VIm: copy match with cursor position atom to local variable

I'm searching for a way to copy match result to local variable in vim script.

The issue is that I want to match text that includes cursor position atom \%#, that is, for example: [A-Za-z:]*\%#[A-Za-z:]\+, which matches identifiers like ::namespace::ParentClass::SubClass text under cursor (so <cword> does not work for me).

I would like to use this later in a script, but the more I dig the more I start to wonder if that's even possible (or: if I should do it differently, by collecting current line, cursor position and then just extract the identifier under cursor manually).

If that's not possible from within the vim script - what would be the idea behind the \%# atom? what is its use?

Aucun commentaire:

Enregistrer un commentaire