The documentation explicitly states that moving the cursor is okay in
an indentexpr, but this is only true when moved directly with cursor(),
setpos(), search(), etc. Moving the cursor via `normal! w` has side
effects that frustrate the attempts of get_expr_indent() to restore the
original cursor position. However, this is not apparent without reading
the source.

For example:

        function! BadIndentExpr()
                normal! $
                return 8
        endfunction
        setlocal indentexpr=BadIndentExpr()

The cursor position is not restored when indenting the current line.
---
 runtime/doc/options.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 3beb2b0..b0ea21c 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -4162,7 +4162,8 @@ A jump table for the options with a short description can 
be found at |Q_op|.
        and |lispindent()|.
        The evaluation of the expression must not have side effects!  It must
        not change the text, jump to another window, etc.  Afterwards the
-       cursor position is always restored, thus the cursor may be moved.
+       cursor position is always restored, thus the cursor may be moved (but
+       not via |:normal| commands).
        Normally this option would be set to call a function: >
                :set indentexpr=GetMyIndent()
 <      Error messages will be suppressed, unless the 'debug' option contains
--
1.8.1.2

-- 
-- 
You received this message from the "vim_dev" 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_dev" 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/groups/opt_out.


Raspunde prin e-mail lui