Text Pastry is a plugin for Sublime Text 2 and gives you the tools to insert a sequence of text or numbers on multiple locations.
Thanks for using the excelent Package Control to install Text Pastry.
To use Text Pastry, we need to open a Document in ST2 and use Multiple Selection to mark the insert locations (in this document also refered to as selections).
Please keep in mind that the selected text could be replaced when we run the Text Pastry command. To avoid that, we can alway place the cursor between letters by using CMD + Click or even select a whole column by using ALT + Click
All we need to do now is to press CMD + ALT + N to open the Text Pastry command line. The input panel will show up at the bottom of ST2.
Now its time to run our first command. Let's enter first second third
and hit enter to run the command. Text Pastry will add first
to our first selection, second
to the next selection and so on.
Text Pastry will only replace as many words as we type into the command line. So if we have more selections then words, the rest of our selection will remain intact.
The default key bindings are stored at /Text Pastry/Default.sublime-keymap. As always, you can use your user keymap file to overrule the default key bindings.
Shortcut | Action |
---|---|
CMD + ALT + T | Show Text Pastry Menu |
CMD + ALT + N | Open Command Line |
Note: The commands from the Text Pastry menu are also available through the Command Palete (CMD + SHIFT + P)
Replaces the first selection with Lorem, the second selection with Ipsum, etc.:
Lorem Ipsum Dolor
Inserts a sequence, starting at 1:
\i
Inserts a sequence, starting at 0:
\i0
Inserts a sequence by defining start index and step size:
\i(N,M)
N
the start indexM
the step size
Note: The Number Sequence command uses the syntax from TextPad.
Additionally, we can leave the brackets away if we want to:
\i1000,100
Inserts the content of the clipboard into our selections by splitting the words:
\p
Same as above with a specified string separator:
\p(sep)
sep
the string separator used to split the clipboad data.
Note: The Clipboard command uses syntax from TextPad.
NEW Text Pastry will generate a UUID for each selection we have made:
\uuid
This command will generate a random UUID by using pythons uuid.uuid4() method:
dbf8326e-5243-406e-abd9-bd0425d3e842
We can use the following command to generate a random UUID in UPPERCASE:
\UUID
Text Pastry has a build in support for the Insert Nums syntax by providing three numbers separated by one space:
N M P
N
: the start index.M
represents the step size which will be added to the index for each selection.P
must be > 0 and will be used to pad the index with leading zeroes.
Note:
Here are some examples, assuming we have selected every ocurence of null
and Text Pastry was called by pressing CMD + ALT + N:
Enter a list of words, separated by one space, into the command line:
INPUT SELECT TEXTAREA DIV P A
var a = document.getElementsByTagName('null');
var b = document.getElementsByTagName('null');
var c = document.getElementsByTagName('null');
var d = document.getElementsByTagName('null');
var e = document.getElementsByTagName('null');
var f = document.getElementsByTagName('null');
var a = document.getElementsByTagName('INPUT');
var b = document.getElementsByTagName('SELECT');
var c = document.getElementsByTagName('TEXTAREA');
var d = document.getElementsByTagName('DIV');
var e = document.getElementsByTagName('P');
var f = document.getElementsByTagName('A');
###Using the Clipboard###
The same as above, but this time we copy the list of words into our clipboard:
INPUT SELECT TEXTAREA DIV P A
Insert this into the input panel:
\p
var a = document.getElementsByTagName('null');
var b = document.getElementsByTagName('null');
var c = document.getElementsByTagName('null');
var d = document.getElementsByTagName('null');
var e = document.getElementsByTagName('null');
var f = document.getElementsByTagName('null');
var a = document.getElementsByTagName('INPUT');
var b = document.getElementsByTagName('SELECT');
var c = document.getElementsByTagName('TEXTAREA');
var d = document.getElementsByTagName('DIV');
var e = document.getElementsByTagName('P');
var f = document.getElementsByTagName('A');
If we copy following list, we will get the same result:
INPUT
SELECT
TEXTAREA
DIV
P
A
Lets assume we want to paste some test data into our code:
71602 White Hall
71603 Pine Bluff
71611 Pine Bluff
71612 White Hall
71613 Pine Bluff
71630 Arkansas City
71631 Banks
71635 Crossett
71638 Dermott
71639 Dumas
This command will tell Text Pastry to split up our clipboard data by using the newline character as separator:
\p(\n)
var a = load('null');
var b = load('null');
var c = load('null');
var d = load('null');
var e = load('null');
var f = load('null');
var a = load('71602 White Hall');
var b = load('71603 Pine Bluff');
var c = load('71611 Pine Bluff');
var d = load('71612 White Hall');
var e = load('71613 Pine Bluff');
var f = load('71630 Arkansas City');
Each line of the clipboard data will be stripped/trimmed, so there won't be any leading spaces.
The following list would therefore give us the same result when we use \p(\n) as command:
Data without leading/trailing whitespace
INPUT
SELECT
TEXTAREA
DIV
P
A
Data with leading whitespace:
INPUT
SELECT
TEXTAREA
DIV
P
A
We can change this behaviour in the <Packages>/Text Pastry/TextPastry.sublime-settings file:
"clipboard_strip_newline": false
Start at 1, adding 1 for each selection:
\i
var a = null;
var b = null;
var c = null;
var a = 1;
var b = 2;
var c = 3;
Start at 1000, adding 100 for each selection:
\i(1000,100)
var a = null;
var b = null;
var c = null;
var a = 1000;
var b = 1100;
var c = 1200;
You can also use negative numbers to create a negative sequence:
\i(100,-10)
var a = null;
var b = null;
var c = null;
var d = null;
var e = null;
var f = null;
var a = 100;
var b = 90;
var c = 80;
var d = 70;
var e = 60;
var f = 50;
1 100 1
var a = null;
var b = null;
var c = null;
var d = null;
var e = null;
var f = null;
var a = 1;
var b = 101;
var c = 201;
var d = 301;
var e = 401;
var f = 501;
1 1 3
var a = null;
var b = null;
var c = null;
var d = null;
var e = null;
var f = null;
var a = 001;
var b = 002;
var c = 003;
var d = 004;
var e = 005;
var f = 006;
Command List OverlayCommand HistoryUUID generationSettings for word manipulation- Paste as Block
- Add documentation for menu and history
- Alphabetical sequence (upper/lower case)
- Random numbers
For further information please take the time to look at following links:
- Sublime Text 2: http://www.sublimetext.com/
- Sublime Package Control: http://wbond.net/sublime_packages/package_control
- Insert Nums: https://bitbucket.org/markstahler/insert-nums/
- TextPad: http://www.textpad.com