GithubHelp home page GithubHelp logo

karbassi / text-pastry Goto Github PK

View Code? Open in Web Editor NEW

This project forked from duydao/text-pastry

0.0 3.0 0.0 154 KB

Plugin for Sublime Text. Insert/Paste a range of words, numeric sequences or UUIDs at once

License: MIT License

text-pastry's Introduction

Text Pastry

Text Pastry is a plugin for Sublime Text that will give you the necessary tools to insert or paste a bunch of text, a range of numbers or generated UUIDs into your selected locations.

Ever wanted to paste incrementing numbers or five lines from your clipboard into five different locations at once? Text Pastry can help you out!

What's new

  • 1.3.6: Bugfix release #14
  • 1.3.5: History navigation, command shortcuts - Thanks @JAStanton
  • 1.3.4: Fixed for Sublime Text 3 - Thanks @forcey
  • 1.3.3: New commands: \r(regexp) and \r regex
  • 1.3.2: Bugfix release

Release Notes 1.3.5

  • history can be accessed by up/down arrows in the Text Pastry command line. #13
  • text insert will only be executed if we have a list of three or more words in it. we can use the words command to lift this restriction
  • commands don't require a leading backslash anymore (but it will still work for backwards compatibility)
  • commands are now defined in TextPastry.sublime-settings. Don't like our syntax? Setup your own!

Changes in 1.3.5

I always found it quiet annoying to use the backslash. with the change on text inserts, it's easier to differentiate between those cases. Examples:

Old Syntax (still works) New Syntax (will do the same)
\p p
\p\n pn
\i(100,50) 100 50
\uuid uuid

Installation

Thanks for using the excelent Package Control to install Text Pastry.

We can do a manuall installation by cloning this repository into our Packages folder. Sublime Text -> Preferences -> Browse Packages...

git clone [email protected]:duydao/Text-Pastry.git

Usage

To use Text Pastry, we need to open a Document in Sublime Text and use Multiple Selection to mark the insert locations (in this document also referred 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 Sublime Text.

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.

Key Bindings

The default key bindings are stored at /Text Pastry/Default.sublime-keymap. As always, you can use your user keymap file to setup your own key bindings.

Linux / Windows Mac Action
CMD + ALT + T CTRL + ALT + T Show _Text Pastry_ Menu
CMD + ALT + N CTRL + ALT + N Open _Text Pastry_ Command Line
CMD + ALT + F CTRL + ALT + F Open _Text Pastry_ Command Line

Note: The commands from the Text Pastry menu are also available through the Command Palette (CTRL/CMD + SHIFT + P)

Command Reference

Regular Text

Replaces the first selection with Lorem, the second selection with Ipsum, etc.:

Lorem Ipsum Dolor

Note: Since version 1.3.5, there must be at least three words before this command will be executed. This change will make it possible to define commands without escape character.

We can still use a list of any size by prepeinding the words command:

words Lorem Ipsum

Number Sequence

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 index
  • M the step size

Start index and step size may be negative.

Note: The Number Sequence command uses the syntax from TextPad.

Additionally, we can leave the brackets away if we want to:

\i1000,100

even this will work:

1000 100

Clipboard

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.

UUID

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

Regular Expression as separators

We're able to define regex separators for the data that we are pasting, which should give us some new possibilities.

We can split the clipboard data by regex, and paste the resulting items into the selected locations:

\r(regex)

or

\r regex

Note: If you managed to get python-pcre up and running, the library will be preferred over the default python re library.

Insert Nums

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:

Examples

Check out the wiki for examples!

Todo

  • Alphabetical sequence (upper/lower case)
  • Random numbers, strings and sequences
  • Command List Overlay
  • Command History
  • UUID generation
  • Settings for word manipulation
  • Paste as Block

License

The MIT License (MIT)

Copyright (c) 2014 Duy Dao, https://github.com/duydao/Text-Pastry

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

See Also

For further information, please take the time to look at following links:

text-pastry's People

Contributors

duydao avatar jbrooksuk avatar adzenith avatar forcey avatar

Watchers

Ali Karbassi avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.