I'm trying to write a vim syntax file, one problem I'm dealing with is vim's regex syntax is different from most other languages(I think the one called "perl compatible regex", Python, JavaScript etc. uses mostly the same regex syntax) and so I can't use regex testers like regexpal.
What is the easiest way to try vim regexes ? Ideally what I want is two splits, in one I'll write vim regex, and the other one will have the text, and matched parts should be highlighted.
Thanks in advance.
EDIT: I added a modified version of Ingo Karkat's answer to my .vimrc
:
nnoremap <F5> mryi":let @/ = @"<CR>`r
This version also puts cursor back where it was when pressed F5 with the cost of losing mark r
.
Do this in Vim. For syntax files, you often deal with start="^begin"
stuff. Yank the regexp via yi"
, then highlight it via:
:let @/ = @"
Of course, if you need this often, bind this to a mapping (and :set hlsearch)
, like:
:nnoremap <F5> yi":let @/ = @"<CR>