Easiest way to check vime regex?

I'm trying to write a vim syntax file, one problem I'm dealing with is that the syntax of the vim syntax is different from most other languages ​​(I think the one called "perl compatible regex", Python, JavaScript, etc., uses basically the same regex syntax), and therefore I cannot use regex testers like regexpal.

What is the easiest way to try vym regexes? Ideally, I want it twice, in one I will write vim regex, and the other will have text, and the corresponding parts should be highlighted.

Thanks in advance.

EDIT: I added a modified version of Ingo Karkat to my .vimrc :

 nnoremap <F5> mryi":let @/ = @"<CR>`r 

This version also returns the cursor to where F5 was pressed, with the loss of the r mark.

+6
source share
4 answers

Do it in Wim. For syntax files, you often deal with start="^begin" . Put the regular expression with yi" , then select it with:

 :let @/ = @" 

Of course, if you need it often, bind this to a mapping (and :set hlsearch) , for example:

 :nnoremap <F5> yi":let @/ = @"<CR> 
+5
source

Use vim to check for regex. By typing / in vim , you can search for material, and the search uses a regular expression.

See vimregex for syntax help

+4
source

We can access the Vim registers in Ex mode or in search mode by pressing Ctrl + R , and then the register that you want to paste.

In your situation, we can use this to copy the text we want to check, and then paste it into our search.

y i " / Ctrl + R 0 CR

Explanation:

y i " → Yankees inside double quotes "
/ → Open the search field
Ctrl + R 0 → paste last drawn text

+2
source

You can also try RegExr. This is a good tool to learn RegEx and try them out in real time.

0
source

All Articles