Skip to content

Commit

Permalink
docs: custom pattern example for stopping only at words with 3+ chars
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Dec 19, 2023
1 parent 2cda32b commit f601b2a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# nvim-spider 🕷️🕸️
<!-- LTeX: enabled=true -->
<a href="https://dotfyle.com/plugins/chrisgrieser/nvim-spider">
<img src="https://dotfyle.com/plugins/chrisgrieser/nvim-spider/shield" /></a>
<img alt="badge" src="https://dotfyle.com/plugins/chrisgrieser/nvim-spider/shield"/></a>

Use the `w`, `e`, `b` motions like a spider. Move by subwords and skip
insignificant punctuation.
Expand Down Expand Up @@ -160,13 +160,18 @@ options.
A few examples:

```lua
-- The motion stops at the beginning of the next number.
-- The motion stops only at numbers.
require("spider").motion("w", {
customPatterns = { "%d+" },
})

-- The motion stops only at hashes like `ef82a2`. (There is not quantifier like
-- `{5,}` in lua patterns, making the repetition necessary.)
-- The motion stops at only at words with at least 3 chars or at any punctuation.
-- (Lua patterns have no quantifier like `{3,}`, thus the repetition.)
require("spider").motion("w", {
customPatterns = { "%w%w%w+", "%p+" },
})

-- The motion stops only at hashes like `ef82a2`.
require("spider").motion("w", {
customPatterns = { "[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]+" },
})
Expand Down

0 comments on commit f601b2a

Please sign in to comment.