I wrote a little Vim function that moves the cursor to the first character of the current line. If the cursor was already on the first character, then the cursor is moved to the first column instead.

" Jump to first character or column
noremap H :call FirstCharOrFirstCol()<cr>

:function! FirstCharOrFirstCol()
:  let current_col = virtcol('.')
:  normal ^
:  let first_char = virtcol('.')
:  if current_col == first_char
:    normal 0
:  endif

How do I call this function silently? I’d rather ‘:call FirstCharOrFirstCol()’ wasn’t displayed in the status line. Simply changing to noremap H :silent call… doesn’t seem to be enough.

  • 10
    Just a small note: in a VimScript file (i.e. *.vim), you never need the leading : characters.
    – tommcdo
    Commented May 25, 2015 at 14:22

1 Answer 1


You can call the function silently by defining a silent map:

noremap <silent> H :call FirstCharOrFirstCol()<cr>

For more info, see :h :map-<silent>. Note in particular that this will only ensure that the command is not echoed to screen when the mapping is executed. The :silent command is used to silence output from the function itself, and with a ! to silence all errors (see :h :silent).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.