0

This is an example script which is meant to print the keyboard shortcut for a command.

Applying it clears the screen output. The result of commands like intro or version get cleared off the screen when it is enabled. Currently it only calls echomsg when the last command is tabnew yet the screen gets cleared when any other command is applied.

Why is this happening?

cnoremap <silent> <cr> <cr>:call <SID>CommandCallback()<cr>

function! s:CommandCallback()
  let last_command = @:

  if last_command =~ 'tabnew'
    echomsg "Tabnew was called"
  endif
endfunction

PS: The question where this script came from - https://stackoverflow.com/questions/43691961

  • 2
    Because of everything else in the mapping. Suggestion: you might find 'titlestring' more convenient as a place to display information. – Antony May 5 '17 at 6:34
  • @Antony By titlestring do you mean titlestring "Tabnew was called"? – vfclists May 5 '17 at 6:43
  • 1
    I mean the 'titlestring' option. – Antony May 5 '17 at 6:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.