Skip to main content
The 2024 Developer Survey results are live! See the results

New answers tagged

2 votes

Correctly escaping <CR>: how can I map a command to send the literal string "<CR>" to a vim function?

Just don't escape it and leave for nnoremap to proceed. Then you get byte#13 inside the quotes exactly as needed. Another option is \r or \x0d like in normal C string. Of course, there is also <lt&...
Matt's user avatar
  • 21.1k
3 votes

Correctly escaping <CR>: how can I map a command to send the literal string "<CR>" to a vim function?

@Heptite found a solution in the comments: I can escape < to <lt>. :nnoremap <F4> :call term_sendkeys(term_list()[0], "python models.py -m something\<lt>CR>")<CR&...
Martín Fixman's user avatar
3 votes

Correctly escaping <CR>: how can I map a command to send the literal string "<CR>" to a vim function?

You should extract the whole RHS of your mapping into a function that you call from the mapping: function! MyFunc() call term_sendkeys(term_list()[0], "python models.py -m something\<CR>...
romainl's user avatar
  • 41.5k

Top 50 recent answers are included