|
| 1 | +# Instant Count |
| 2 | +[](https://marketplace.visualstudio.com/items?itemName=adnv3k.instant-count) |
| 3 | + |
| 4 | +> _Instantly count highlighted text, words, or fully-custom patterns – with live gutter badges, status-bar feedback, and one-click configuration._ |
| 5 | +
|
| 6 | + |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## ✨ At a Glance |
| 11 | +| Feature | What it does | |
| 12 | +| :-- | :-- | |
| 13 | +| **Real-time Counter** | Status-bar number updates as you type or select | |
| 14 | +| **Numbered Badges** | Occurrence index drawn in the editor gutter | |
| 15 | +| **One-click Panel** | Click the counter to toggle case/word/regex, enter rules, etc. | |
| 16 | +| **Peek / Select-All** | View or multi-cursor-select every match in one command | |
| 17 | +| **Custom Rules** | `$TEXT` / `$RAWTEXT` placeholders turn any selection into a regex | |
| 18 | +| **Safe & Fast** | Chunked scanning, regex timeout guard, view-port badge rendering | |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## 🚀 Quick Start |
| 23 | +1. **Install** from the VS Code Marketplace: `instant-count`. |
| 24 | +2. **Select** text (or just place the cursor on a word). |
| 25 | +3. Watch the **status-bar counter** and **gutter badges** appear. |
| 26 | +4. Hit `Ctrl + Shift + R` to open the quick-config panel. |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## 🔍 Advanced Regex Recipes |
| 31 | + |
| 32 | +Below are four ready-to-paste rule examples in the same format used inside the extension. |
| 33 | + |
| 34 | +**Example 1: Untranslated i18n Keys** |
| 35 | +- **Select:** `t(` |
| 36 | +- **Regex Rule:** `t\(\s*"(en\.)[^"]+"\s*\)` |
| 37 | +- **Result:** Flags `t("en.some.key")` calls still hard-coded to English. |
| 38 | + |
| 39 | +**Example 2: Left-over `console.*` Calls** |
| 40 | +- **Select:** `console` |
| 41 | +- **Regex Rule:** `(^|\s)(console\.(log|debug|warn|error))\s*\(` |
| 42 | +- **Result:** Catches any `console.log`, `.debug`, `.warn`, `.error` still lurking in code. |
| 43 | + |
| 44 | +**Example 3: Duplicate Words** |
| 45 | +- **Select:** `the` (or any word) |
| 46 | +- **Regex Rule:** `\b$TEXT\s+$TEXT\b` |
| 47 | +- **Result:** Finds “the the”, “return return”, etc., regardless of the word you pick. |
| 48 | + |
| 49 | +**Example 4: JSX Components Missing a Prop** |
| 50 | +- **Select:** `MyButton` |
| 51 | +- **Regex Rule:** `<MyButton\b(?![^>]*\bonClick=)` |
| 52 | +- **Result:** Highlights every `<MyButton …>` with no `onClick=` prop. |
| 53 | + |
| 54 | +### Custom Rule in Action |
| 55 | + |
| 56 | +| Before | After | |
| 57 | +|:--:|:--:| |
| 58 | +|  |  | |
| 59 | + |
| 60 | +--- |
| 61 | + |
| 62 | +## ⚙️ Configuration Reference |
| 63 | + |
| 64 | +| Setting | Default | Description | |
| 65 | +| :-- | :--: | :-- | |
| 66 | +| `instant-count.caseSensitive` | `false` | Match case exactly | |
| 67 | +| `instant-count.wholeWord` | `false` | Add `\b…\b` boundaries | |
| 68 | +| `instant-count.useRegex` | `false` | Treat search pattern as regex | |
| 69 | +| `instant-count.showGutterBadges` | `true` | Toggle numbered badges | |
| 70 | +| `instant-count.showInStatusBar` | `true` | Toggle status-bar counter | |
| 71 | +| `instant-count.regexRules` | `""` | Custom rule with `$TEXT` / `$RAWTEXT` | |
| 72 | + |
| 73 | +_Open **Command Palette → “Instant Count: Settings”** for the interactive panel._ |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +## ⌨️ Useful Commands |
| 78 | + |
| 79 | +| Command | Keybinding | What it does | |
| 80 | +| :-- | :--: | :-- | |
| 81 | +| Toggle Case | none | Switch case sensitivity | |
| 82 | +| Toggle Whole Word | none | Add/remove word boundaries | |
| 83 | +| Toggle Regex Mode | none | Literal ↔ regex | |
| 84 | +| Peek All Matches | `Ctrl + Shift + 3` | Open VS Code peek panel | |
| 85 | +| Select All Matches | `Ctrl + Shift + Alt + S` | Multi-cursor select | |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +## 🛡 Performance & Safety |
| 90 | + |
| 91 | +* Chunked scanning keeps UI fluid even on **10 MB+** files. |
| 92 | +* Regex execution has a **500 ms timeout guard** to avoid catastrophic back-tracking freezes. |
| 93 | +* Badges are only rendered inside (and near) the view-port for zero scroll-lag. |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +## 🤝 Contributing |
| 98 | + |
| 99 | +1. Fork the repo, `npm install`, press **F5** to launch the *Extension Host*. |
| 100 | +2. Submit pull-requests against the `dev` branch. |
| 101 | +3. All contributions are released under the MIT license. |
| 102 | + |
| 103 | +--- |
| 104 | + |
| 105 | +## 📜 License |
| 106 | + |
| 107 | +[MIT](LICENSE) © 2025 Ali Do |
| 108 | + |
| 109 | +## 🤝 Contributing |
| 110 | + |
| 111 | +PRs are welcome! |
| 112 | +1. Fork the repo · 2. `npm install` · 3. Press **F5** to launch the Extension Host · 4. Submit a pull-request to `main`. |
| 113 | + |
| 114 | +## 🚀 Install |
| 115 | + |
| 116 | +[](https://marketplace.visualstudio.com/items?itemName=adnv3k.instant-count) |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +> _Made with ♥ and a lot of regex._ |
0 commit comments