From f21221e63a2be3ca0de4dfdf08d37a4e437e7824 Mon Sep 17 00:00:00 2001 From: logworthy Date: Mon, 16 Dec 2019 06:36:09 +1100 Subject: [PATCH 1/4] Added itertools to pre-imported modules (#24) --- InsertNums.py | 3 ++- README.md | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/InsertNums.py b/InsertNums.py index 10ddea0..74f7c20 100644 --- a/InsertNums.py +++ b/InsertNums.py @@ -4,6 +4,7 @@ # Modules for expression evaluation import math import random +import itertools import sublime import sublime_plugin @@ -339,7 +340,7 @@ def run(self, edit, format='', quiet=False): env = dict( _=value, i=i, p=eval_value, s=step, n=len(selections), # Modules - math=math, random=random, re=re + math=math, random=random, re=re, itertools=itertools ) if EXPRMODE: del env['s'] # We don't need the step here diff --git a/README.md b/README.md index e14aba9..29d1d87 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ Detailed syntax definition: [format_syntax.txt](format_syntax.txt) - `i`: Just an integer holding the counter for the iteration; starts at `0` and is increased by `1` in every loop - `_`: The current value before the expression (`start + i * step`) - `p`: The result of the previously evaluated value (without formatting); `0` for the first value - - `math`, `random` and `re`: Useful modules that are pre-imported for you + - `math`, `random`, `re` and `itertools`: Useful modules that are pre-imported for you *Note*: The return value does not have to be a number type, you can also generate strings, tuples or booleans. @@ -271,6 +271,20 @@ The `|` pipe is used to show the meaning of piping the current selection to the 25 36 ``` + +- `::list(itertools.product(['a', 'b', 'c'], ['x', 'y', 'z']))[i]` + + ``` + ('a', 'x') + ('a', 'y') + ('a', 'z') + ('b', 'x') + ('b', 'y') + ('b', 'z') + ('c', 'x') + ('c', 'y') + ('c', 'z') + ``` ### Alpha insert @@ -406,6 +420,7 @@ And many more ... - Marco Novaro, [@MarcoNovaro](https://github.com/MarcoNovaro) - Oleg Geier, Twitter: [@relikd](https://twitter.com/relikd) - Arthur Comben, Twitter: [@anthillape](https://twitter.com/anthillape) +- [@logworthy](https://github.com/logworthy) # License From 103cd7f2986e50020944c43cc15a8926a84eb9ff Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 28 Jan 2024 22:06:43 +0100 Subject: [PATCH 2/4] Declare support for Python 3.8 Does not break compatibility with ST3 by itself since the file is simply ignored there. --- .python-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .python-version diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..cc1923a --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.8 From 814f03564549cd40cf9c2f171759b3df1ed09dc8 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Thu, 11 Apr 2024 08:33:52 +0100 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 29d1d87..d0df4ec 100644 --- a/README.md +++ b/README.md @@ -415,7 +415,7 @@ And many more ... ## Contributors -- [James Brooks](http://james.brooks.so), Twitter: [@jbrooksuk](https://twitter.com/jbrooksuk) +- [James Brooks](http://pinkary.com/@jbrooksuk), Twitter: [@jbrooksuk](https://twitter.com/jbrooksuk) - [@FichteFoll](https://github.com/FichteFoll), Twitter: [@FichteFoll](https://twitter.com/FichteFoll) - Marco Novaro, [@MarcoNovaro](https://github.com/MarcoNovaro) - Oleg Geier, Twitter: [@relikd](https://twitter.com/relikd) From 4699ddf7caae126638cd7b519dd0864de366d816 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 4 May 2024 08:57:30 +0200 Subject: [PATCH 4/4] Update README.md (#30) This commit... 1. updates initial description section and removes ST version numbers. 2. updates installation instructions. --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d0df4ec..3644fac 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,49 @@ -# Insert Nums for Sublime Text 2 and 3. +# Insert Nums -A **Sublime Text 2 and 3** plugin, that inserts (consecutive) numbers across multiple selections or modifies the selections' contents with expressions. Huge configurability. +A [Sublime Text](https://www.sublimetext.com) plugin, +to insert (consecutive) numbers across multiple selections +or modifiy selections' contents +with expressions using sophisticated expressions syntax. ## Installation -You can install *Insert Nums* via [Package Control][pkgctrl] by searching for **Insert Nums**. +### Package Control -Alternatively, you can download the Zip and copy it to your Sublime Text Packages folder, or use `git clone`. +The easiest way to install is using [Package Control](https://packagecontrol.io). It's listed as `Insert Nums`. + +1. Open `Command Palette` using ctrl+shift+P or menu item `Tools → Command Palette...` +2. Choose `Package Control: Install Package` +3. Find `Insert Nums` and hit Enter + +### Manual Setup + +Alternatively, you can clone this repository into Sublime Text's Packages folder. + +> [!NOTE] +> +> To find _Packages_ folder call _Menu > Preferences > Browse Packages.._ + +#### OSX + +```sh +#!/usr/bin/env bash +cd ~/Library/Application\ Support/Sublime\ Text/Packages/ +git clone https://github.com/SublimeText/InsertNums "Insert Nums" +``` + +#### Linux + +```sh +cd ~/.config/sublime-text/Packages +git clone https://github.com/SublimeText/InsertNums "Insert Nums" +``` + +#### Windows + +```dos +cd "%APPDATA%\Sublime Text\Packages" +git clone https://github.com/SublimeText/InsertNums "Insert Nums" +``` ## Usage