The following is from vim-sensible plugin:

set incsearch
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
  nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>

As far as I know, ==# is "always case-sensitive" operator. But what is the purpose to use it when we are compare something to empty string?

And also, what does the entire if maparg('<C-L>', 'n') ==# '' line mean?


1 Answer 1


:help maparg() explains that maparg('<C-L>', 'n') will return the normal mode mapping assigned to control-L.

When there is no mapping for <C-L>, then it will return an empty string...so it's politely checking for the existence of a mapping before assign the mapping.

Concerning ==# with an empty string, some plugin authors automatically use ==# all the time without considering who it may confuse. :)

  • 1
    Note the possibility of empty() in this case which is clearer, though I am indeed among those who use ==#/is# for comparisons almost every tme—the link in the comments is a good one. (Same reason you should use === in javascript unless you really truly know better.)
    – D. Ben Knoble
    Sep 9, 2021 at 12:05

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.