4
votes
Accepted
Is there a Vim plugin for testing VimScript patterns?
There is a very simple way, for which you do not need any plugin. Open a file with some content, turn on :set incsearch and/or :set hlsearch and try it out interactively with Vim.
That's how you learn ...
4
votes
Prevent jumping when pattern matching
This will do for the * search, I'm not sure how to do that for /.
nnoremap <silent> * :let @/= '\<' . expand('<cword>') . '\>' <bar> set hls <cr>
@/ is the search ...
4
votes
Accepted
What is the shortest search pattern that matches nowhere?
You've gotten a better answer in the comments, but for curiosity's sake, note that unless you add atoms specifically to avoid this, patterns will generally only match in a single line.
So there are a ...
2
votes
Accepted
Can you get a count on a search where the count is > 1000 matches?
You can use the :s[ubstitute] command's n flag. As described under :h count-items:
To count how often any pattern occurs in the current buffer use the substitute command and add the 'n' flag to avoid ...
2
votes
"wildignore" and "\{n,m}" type patterns
There are two issues here.
First, 'wildignore' takes a list of separate patterns, split by comma, so you actually need to escape the comma with a backslash for it to work inside the \\\{n,m\} pattern ...
2
votes
Accepted
What is the pattern matched against for events CmdwinLeave and CmdwinEnter?
Those things are easy to test with :help <amatch>:
autocmd! CmdWinLeave * echomsg expand('<amatch>')
Where you use a wildcard to catch every possible case and echo <amatch> in the ...
2
votes
Accepted
How to escape commas in au patterns and comma separated lists?
For comma in file pattern you have to escape with \,.
au BufEnter *\,*.txt echo 'this file has a comma in its name'
More information with :help file-pattern:
The pattern is interpreted like mostly ...
1
vote
Usage of pattern for ilist command
While :help :ilist can be used to print lines matching a given pattern, it is not really designed for that.
Combining :help :global and one of :help :list, :help :print, :help :number, :help :#, and :...
1
vote
Is there a Vim plugin for testing VimScript patterns?
The trace provide you a preview of the substitution and privide a good help to learn regular expression patterns.
If you are using Neovim you could also be interested by hypersonic
1
vote
Accepted
How to match latin letters + their accented versions?
I've discovered the \k character class, which matches anything that is in 'iskeyword', which can in turn be set iskeyword=@, where the meaning of @ is explained at isfname:
If the character is '@', ...
1
vote
What is the pattern matched against for events CmdwinLeave and CmdwinEnter?
The documentation makes this clear I believe:
:h CmdwinLeave mentions this:
<afile> is set to a single character,
indicating the type of command-line.
|cmdwin-char|
(same for :h CmdwinEnter)
...
1
vote
Accepted
What pattern should I use for word-like movement?
First, we must understand how exactly vim implements the w command.
To start with, vim assigns every character a "class," where numerically: blank = 0, punctuation = 1, word = 2, emoji = 3, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
pattern × 14regular-expression × 4
autocmd × 4
neovim × 2
search × 2
events × 2
match × 2
vimrc × 1
vimscript × 1
command-line × 1
unicode × 1
plugin × 1
vimscript-lua × 1
counting × 1
lua × 1
default-settings × 1
jump × 1
matchadd × 1
undocumented-behaviour × 1