Is there a setting I could add to my vimrc file that would hide the last entered colon-command that stays visible on the bottom of the screen after I hit enter?

For example, if I type ":3" to go to line 3 of the current file, then the ":3" stays visible on the bottom of the screen even after I hit enter. I already have my manager on my back. Now, I have a little guy with a mustache at the bottom of my screen staring at me while I'm trying to get my work done. (I know there are other ways to go to line 3—for example, by entering "3G"—that keep the command-line clear, but you get the point.)

I think I'd like to hide the last entered command because I like to keep things clean. I'm not very experienced with Vim, however, so if keeping the last command visible is actually more useful than I realize, please do enlighten me.

Also, what about for searches? Maybe if I enter "/hello" (to search for all occurrences of "hello"), for example, then I could type "Esc" (or something) to clear "/hello" from the command-line when I'm done searching. How could I make something like that possible? Or, is there already a setting or plugin that does this?

3 Answers 3


You can press <C-l> to force a redraw, which will clear this line, among some other things.

If you want, you can use the CmdlineLeave autocommand to echo an empty string upon leaving the commandline:

augroup cmdline
    autocmd CmdlineLeave : echo ''
augroup end

There isn't a setcmdline(), so as far as I know this is the best way.

This won't work for search, as searching for text will always set the commandline window (e.g. n will set it). I don't know of any way to automatically clear that outside of pressing <C-l> or remapping all search keys:

nnoremap n n:echo ''<CR>
" same for N, *, etc.

You can hide the last colon command or search pattern from the bottom of the screen by typing : or / and then Backspace (or Delete on macOS) or Esc (or Ctrl[).

  • I like to append :<BS> to mappings to hide command-line output. To fully hide everything, I had to split one command into two: nnoremap <silent> <Plug>nohlsearch :<C-u>nohlsearch<CR> nmap <nowait> Z <Plug>nohlsearch:<BS>. This makes Z hide both hlsearch and any command-line output left there.
    – awvalenti
    Commented Feb 19 at 21:35

Marin Tournoij's answer didn't work for me as written; entering a command was overriding echo ''. It gave me an idea though. The code below is the same approach, but on a slight delay.

(Also, his command had a colon : in it, but I think that's supposed to be an asterisk * to signify the autocmd works on any file pattern. Edit: Knoble's comment below clarified this.)

augroup clearcmdline
    function! Echo_Nothing(timer)
        echo ''
    autocmd CmdlineLeave * call timer_start(1000, 'Echo_Nothing')
augroup END

Explanation: timer_start() requires a time in milliseconds and the name of a callback function. Instead of 1000, use 0 if you want these messages to instantly disappear. It's a lot of fuss, but it works.

  • 2
    The pattern for CmdlineLeave is what "type" of command, so : vs. /, etc. (:help cmdwin-char)
    – D. Ben Knoble
    Commented Oct 19, 2021 at 14:13

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.