Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from jbrooksuk/InsertNums@master #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8
3 changes: 2 additions & 1 deletion InsertNums.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Modules for expression evaluation
import math
import random
import itertools

import sublime
import sublime_plugin
Expand Down Expand Up @@ -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
Expand Down
64 changes: 58 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <kbd>ctrl+shift+P</kbd> or menu item `Tools → Command Palette...`
2. Choose `Package Control: Install Package`
3. Find `Insert Nums` and hit <kbd>Enter</kbd>

### 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

Expand Down Expand Up @@ -105,7 +142,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.

Expand Down Expand Up @@ -271,6 +308,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

Expand Down Expand Up @@ -401,11 +452,12 @@ 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)
- Arthur Comben, Twitter: [@anthillape](https://twitter.com/anthillape)
- [@logworthy](https://github.com/logworthy)

# License

Expand Down