Is there an easy way to save a commonly used Regex pattern so that I can reuse it between different files? I look through many log files and always need create a mildly complex regex (it's not rocket science but it is a pain to retype) to find errors so it would be good to have a way to recall that without having to save it in a text file and paste it into the search params each time.
vim which translates from PCRE (Perl-compatible regular expressions) to Vim's regex syntax. This will make it more likely for regexes from other environments to work, because PCRE have become the de facto industry standard: e.g. Java's java.
Put:
source ~/.regexlist.vim
into your vimrc.
Do the search. Decide you might want to use that one again. Type this literally:
:sp ~/.regexlist.vim<CR> olet MyRegExName = '<C-R>/'<ESC> :w<CR> :so %<CR> :q<CR>
Where <C-R>
is CtrlR, <CR>
is ENTER and <ESC>
is ESC.
Next time you want to use it:
/<C-R>=MyRegExName<CR><CR>
Ctrl-R is your friend! Ctrl-R followed by / pulls up the last search. Ctrl-R followed by = allows you to enter an expression.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With