[TUHS] :nohlsearch in vim

Chris Torek torek at elf.torek.net
Thu Nov 16 08:42:31 AEST 2017


>`:noh' turns off the highlighting of the current matches.

YAY!

I've been using Arthur Krewat's method, basically /asdf<CR>,
for a long time now.  Now I have:

    map <Leader><Leader> :nohlsearch<CR>

in my .vimrc (<Leader> is backslash, so after /foo<CR>, \\ turns
off the highlighting).

One other really useful thing, given issues with tabs vs spaces,
that I'll share here, comes just before this new entry:

    function! ToggleTabs()
        if &list
            set nolist
        else
            set list listchars=tab:>.,trail:>,precedes:<
        endif
    endfunction

    map <Leader>t :call ToggleTabs()<CR>

With this, \t makes tabs visible, or invisible if they are
currently visible.  Despite the name it also highlights trailing
whitespace (the highlight is a bit subtle though).

Chris



More information about the TUHS mailing list