To call a function, change the display as follows.
:nnoremap ,, :call MyFunc()<cr>
Usually, displaying an expression is useful for use in Insert mode, since it allows you to dynamically change the sequence of keystrokes in accordance with a special case. If you want to use the expression case to insert text into the buffer in normal mode, you must use the appropriate normal mode command to insert or change the text (for example, i , i , a , a ), followed by the expression case evaluating the text to insert. So mapping
:nnoremap ,, cc<cr>=MyFunc()<cr><esc>
will have the same effect as the first if the MyFunc() function returns a string containing the text to insert:
function! MyFunc() ... return 'text for inserting' endfunction
source share