vim regex the pipe is not escaped in a execute command -


i trying create operator pending mapping markdown headers, exercise in learning vim script hard way here line vimrc:

autocmd filetype markdown :onoremap ih :<c-u>execute "normal! ?\\(^==\\+$\\|^--\\+$\\)\r:nohlsearch\rkvg_"<cr> 

i have error

e486: pattern not found: \(^==\+$|^--\+$\) 

i tried modifications have same result, it's pipe never escaped !

inside :map command, use <bar> instead of pipe symbol:

autocmd filetype markdown :onoremap ih :<c-u>execute "normal! ?\\(^==\\+$\\<bar>^--\\+$\\)\r:nohlsearch\rkvg_"<cr> 

that long :normal command (that executes search, ex command, , more commands, separated \r) ugly. you'd better use :call search(...) instead of ? command, , factor out multiple commands :function.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -