# expr [toc] ## cmd中的expr取值 :::success ```CTRL-\ e {expr} c_CTRL-\_e Evaluate {expr} and replace the whole command line with the result. You will be prompted for the expression, type <Enter> to finish it. It's most useful in mappings though. See expression. See c_CTRL-R_= for inserting the result of an expression. Useful functions are getcmdtype(), getcmdline() and getcmdpos(). The cursor position is unchanged, except when the cursor was at the end of the line, then it stays at the end. setcmdpos() can be used to set the cursor position. The sandbox is used for evaluating the expression to avoid nasty side effects. Example: :cmap <F7> <C-\>eAppendSome()<CR> :func AppendSome() :let cmd = getcmdline() .. " Some()" :" place the cursor on the ) :call setcmdpos(strlen(cmd)) :return cmd :endfunc This doesn't work recursively, thus not when already editing an expression. But it is possible to use in a mapping. ``` :::