2015-08-10 17:39 GMT+03:00 Graham Lawrence <[email protected]>: > I routinely pass parameters to mappings by simply typing them in at the > beginning of a line and running the mapping which begins 'ld0' > > I reasoned I could extend this principle to functions as follows: > norm "pP0i > sleep 1 > while mode() != "n" | sleep 1 | endwh > norm l"ry0uu > > That is the 'i' in the first 'norm' puts vim in Insert mode, and the while > loop will then wait until the user presses <Esc>. Instead, the function > goes straight to completion, so either I am applying mode() incorrectly, or > vim never enters Insert mode. What am I missing?
This function should be used in status lines, it also works when used with <C-r>=expr, <C-\>e and autocommands. In most other cases it will simply return `'c'`. But what you are missing is not mode() problems, it is :help :normal. Read it carefully, it states explicitly that you *must* end what you need in insert mode because :normal will abort it. Also it is bad idea to use :normal command without a bang. It is slightly less bad idea to use `==` or `!=` for string comparisons: use ==# and !=#. > -- > Graham Lawrence > > -- > -- > You received this message from the "vim_use" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php > > --- > You received this message because you are subscribed to the Google Groups > "vim_use" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
