I'm running the following command, but the \<CR> becomes part of the regular expression in feedkeys...

:call feedkeys("0v/\(,\|$\)\<CR>")

Is there a way to make it an enter keypress instead?

1 Answer 1


The problem is that the backslashes are picked up by the double-quoted string in the feedkeys() command. You'll need to use \\ if you want to pass literal backslashes:

:call feedkeys("0v/\\(,\\|$\\)\<CR>")

This command suffers from a mild case of leaning toothpick syndrome. You can make it a bit simpler by adding \\v so that you don't need to add so many backslashes in the first place:

:call feedkeys("0v/\\v(,|$)\<CR>")

For single quotes strings no backslashes have a special meaning, so you could also use:

:call feedkeys('0v/\(,\|$\)' . "\<CR>")


:call feedkeys('0v/\(,\|$\)^[')

Where ^[ is the literal Enter character (you can enter this by pressing <C-v><Enter>, it should show up in a different colour).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.