0

Using the sparkup plugin for vim (specifically vim-gnome on Ubuntu 15.04, although I doubt that matters), I am generating a list with item numbers:

ion-content.has-tabs > .list > a.item[href=#/item/$]{Item $}*3

The result substitutes the item number in [href=#/item/$] but not in {Item $}:

<ion-content class="has-tabs"> <div class="list"> <a href="#/item/1" class="item">Item $</a> <a href="#/item/2" class="item">Item $</a> <a href="#/item/3" class="item">Item $</a> </div> </ion-content>

Feature, bug, or user error?

radshop
  • 602
  • 5
  • 19

3 Answers3

1

I don't remember Sparkup ever supporting incrementing numbers inside "content" braces so I would say "feature".

Don't waste your time asking for a fix on the plugin's issue tracker, though.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • Thanks for the reply. Up-voting you for answering the question as I literally asked it, but I accepted the other answer because it provided a workaround as well. – radshop Sep 17 '15 at 19:52
0

I am afriad that this plugin deems the $ in curly braces as a text which should not be affected. To numerate your Item $ list, you can try this command

:let @a=1 | %s/\$/\=(@a+setreg('a',@a+1))/g

or for selected block in visual mode

:let @a=1 | '<,'>s/\$/\=(@a+setreg('a',@a+1))/g 
ryuichiro
  • 3,765
  • 1
  • 16
  • 21
0

I accepted an answer to the question as I asked it, but I'm adding this to show an alternate approach for a slightly different requirement. I needed to add a nested tag along with the text, which Sparkup does not support. So I found a single 2-step solution to this that also solved the original item number problem (more complex in my real world solution but simplified here).

This sparkup:

ion-content > .list > a.item.item-icon-left.Item$[href=#/items/$]*3 > i.icon.ion-email

generates this:

<ion-content> <div class="list"> <a href="#/items/1" class="item item-icon-left Item1"> <i class="icon ion-email"></i> </a> <a href="#/items/2" class="item item-icon-left Item2"> <i class="icon ion-email"></i> </a> <a href="#/items/3" class="item item-icon-left Item3"> <i class="icon ion-email"></i> </a> </div> </ion-content>

Then after I select the lines in visual mode, running this:

:'<,'>s/ Item\([0-9]*\)">/">Item \1/g

produces my desired result:

<ion-content> <div class="list"> <a href="#/items/1" class="item item-icon-left">Item 1 <i class="icon ion-email"></i> </a> <a href="#/items/2" class="item item-icon-left">Item 2 <i class="icon ion-email"></i> </a> <a href="#/items/3" class="item item-icon-left">Item 3 <i class="icon ion-email"></i> </a> </div> </ion-content>

radshop
  • 602
  • 5
  • 19