Why: execution doesn't work in Vim: LearnVimscriptTheHardWay

I am trying to learn Vimscript from LearnVimscriptTHWand I came across a usage :execute and :normal.

Example from LVSTHW :

:normal! gg/a<cr>

From the book: The problem is that it normal!does not recognize "special characters", for example <cr>. There are several ways around this, but the easiest way to use and read execute.

Now that I use :execute "normal! gg/a<cr>", this does not work for me. It does not search a(char)in my current file, and not just executes ggand does nothing, but if used :execute "normal! gg/a\r", it works and successfully allocates char ain my file.

I also tried the following methods, but none of them worked.

:execute "normal! gg/a"<cr>
:execute normal! gg/a<cr>
:execute "normal! gg/a<cr>"<cr>

, execute <cr> to \r. , .

+5
2

<cr> : exe "norm! iHello\<cr>World"

+5

:help :execute . <CR> <ESC> : \<CR>, \<Esc>... , .

- "":

  • i ,
  • <C-v>
  • <CR>

, ^M .

+5

All Articles