Author Topic: counted paste macro  (Read 1974 times)

flethuseo

  • Senior Community Member
  • Posts: 177
  • Hero Points: 2
counted paste macro
« on: June 16, 2014, 10:06:22 pm »
I've been thinking this macro could be useful for some tasks I have to perform frequently. Not sure how to go about implementing it but I welcome ideas.

The main idea is that I copy a string, and then each time I paste it, it increments a counter by one that it appends to the end of the string. For example:

I copy the word 'apple'

first time I paste it, I will get 'apple1'
second time 'apple2'
...
nth time 'applen'
« Last Edit: June 16, 2014, 10:08:12 pm by flethuseo »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5514
  • Hero Points: 446
Re: counted paste macro
« Reply #1 on: June 16, 2014, 10:32:16 pm »
Sounds useful. It's a little different than the gui-enumerate command. You could enhance this dialog to do what you want in a more powerful way. It needs a prefix string (possibly pasted text) and a suffix string (may want to append a ',' or whatever) that gets inserted before and after the number. It also needs options when there is no selection like line-break between each item or all on one line. If line-break between each item then just place each item in the same column as the first on a line by itself. The padding options could be improved too. Right now you only have the option to pad with leading zeros. Might want to pad with leading spaces.

Right now this dialog only works when you have a selection. Check it out.

flethuseo

  • Senior Community Member
  • Posts: 177
  • Hero Points: 2
Re: counted paste macro
« Reply #2 on: June 16, 2014, 11:30:16 pm »
I have used enumerate in the past for similar tasks. However, I'm not sure how enumerate can help me when the strings I want to paste will be spread out all over the file in random locations.

Code: [Select]
apple1 ......... blah blah blah <xml>
blah blah <xml> // apple2
blah blah blah <xml>
blah blah blah <xml>
apple3
blah blah blah <xml>
blah blah blah <xml> blah blah blah <xml> apple4
...
just plainly random <xml> apple5 </xml>

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5514
  • Hero Points: 446
Re: counted paste macro
« Reply #3 on: June 16, 2014, 11:53:21 pm »
ok, that can't be handled by gui-enumerate.

Could make a new paste command like paste-enumerate and set global variables for it with a gui or set-var. The options for it are the same ones that would be used by gui-enumerate.

hs2

  • Senior Community Member
  • Posts: 2747
  • Hero Points: 289
Re: counted paste macro
« Reply #4 on: June 17, 2014, 12:13:59 am »
I'd propose using a special copy command to retrieve the text e.g. using ,hs2_cur_word_sel' and (re-)set a static counter appended later by a ,counted_paste' command using ,_insert_text' function.
Good luck, HS2
« Last Edit: June 17, 2014, 12:16:38 am by hs2 »