duydao / Text-Pastry

Extend the power of multiple selections in Sublime Text. Modify selections, insert numeric sequences, incremental numbers, generate uuids, date ranges, insert continuously from a word list and more.
MIT License
832 stars 46 forks source link

Syntax to include space in clipboard text #12

Closed neontapir closed 10 years ago

neontapir commented 10 years ago

Sorry this is long-winded. I think Text Pastry should be able to handle my use case, but I'm having trouble. I'd like to take:

hey there how are you? what's happening?

And get:

greeting1: hey there greeting2: how are you? greeting3: what's happening?

However, I get this instead:

greeting1:hey there greeting2:how are you greeting3:what's happening

I'm having trouble achieving the space character between the colon and the value. Notice also the leading space on lines 2 and 3.

I'm doing the following to get the actual output:

1) Cut this text into the clipboard:

greeting1: greeting2: greeting3:

2) Using CMD + click to insert a cursor in front of each line.

3) Using CMD + ALT + N to enter \p(\n)

I've tried variations with spaces after each colon to no avail.

I believe there are some settings that can change this behavior, but I don't want it all the time, so I'd prefer a way to specify an alternate text separator character.

For example, if I were able to type something like this into CMD + ALT + N:

\s(|) greeting1: |greeting2: |greeting3:

Then Text Pastry would treat space like any other character and use the pipe symbol to delimit the list.

Another option would be to allow backslash escaping of space characters, like so:

greeting1:\ greeting2:\ greeting3:

What do you think? Is this worth pursuing?

duydao commented 10 years ago

Hi Chuck,

you're correct, the setting you would have to change would be clipboard_strip_newline. Setting it to false will preserve whitespace while it would still remove the newline character (since we're splitting by newline \n).

You can even set it by the menu (super/cmt-alt-t -> settings -> strip_newline).

the \p()command already has build-in support for custom seperators, so if you copy this into your clipboard:

\s(|) greeting1: |greeting2: |greeting3: 

using this as command:

\p(|)

you would get the desired result.

However, I'm intrigued by the \s syntax. Do you have a use-case where you would rather type the data (e.g. greeting1: |greeting2: |greeting3: ) into the text pastry input field then use it form the clipboard?

duydao commented 10 years ago

this can already be done with \r(|), no need for an \s switch