Git Product home page Git Product logo

Comments (5)

azabiong avatar azabiong commented on May 26, 2024 1

Great!   I updated documents and added your name to the Credits section to thank you for suggesting this very interesting and useful feature.

 :h Hi-Credits

from vim-highlighter.

aminroosta avatar aminroosta commented on May 26, 2024 1

For anyone else finding this issue via google.
I've gone through a few iterations, and here are my latest mappings, You might find them useful.

" Disable vim's builtin hlsearch highlighting
set nohlsearch

" Disable the cursor guide
let HiCursorGuide = 0

" Highlight the word under the cursor -- `\<' and `\>` are added to match full words only.
nn [oh :Hi + \<<c-r><c-w>\><cr>

" Highlight the text last entered in the '/' register
nn [oH :Hi + <c-r>/<cr>

" We want to keep using the built-in 'n` and 'N' mappings.
" Use the built-in '*' (without affecting the jumplist) and highlight the word under the cursor.
nmap * :keepjumps normal! mi*`i<cr>[oh

" Highlight the word after the command mode search is complete.
cmap <expr> <cr> getcmdtype() == '/' ? '<cr>[oH' : '<cr>'

" Mapping to clear active highlights
nn ( :nohl<cr>:Hi clear<cr>

hi HiColor1 ctermfg=22  ctermbg=194 cterm=bold guifg=#004f00 guibg=#d7f7df gui=bold
hi HiColor2 ctermfg=52  ctermbg=229 cterm=bold guifg=#371700 guibg=#f7f7a7 gui=bold
hi HiColor3 ctermfg=17  ctermbg=195 cterm=bold guifg=#000057 guibg=#afd7fc gui=bold
hi HiColor4 ctermfg=19  ctermbg=189 cterm=bold guifg=#0000af guibg=#d7d7fc gui=bold
hi HiColor5 ctermfg=52  ctermbg=221 cterm=none guifg=#570000 guibg=#fcd757 gui=none
hi HiColor6 ctermfg=17  ctermbg=113 cterm=none guifg=#001767 guibg=#8fd757 gui=none
hi HiColor7 ctermfg=53  ctermbg=219 cterm=none guifg=#570027 guibg=#fcb7fc gui=none
hi HiColor8 ctermfg=89  ctermbg=159 cterm=bold guifg=#87005f guibg=#fcd7fc gui=bold
hi HiColor9 ctermfg=225 ctermbg=90  cterm=none guifg=#ffdff7 guibg=#8f2f8f gui=none
hi HiColor10 ctermfg=195 ctermbg=68  cterm=none guifg=#dffcfc guibg=#5783c7 gui=none
hi HiColor11 ctermfg=52  ctermbg=180 cterm=bold guifg=#570000 guibg=#dfb787 gui=bold
hi HiColor12 ctermfg=223 ctermbg=130 cterm=bold guifg=#fcd7a7 guibg=#af5f17 gui=bold
hi HiColor13 ctermfg=230 ctermbg=242 cterm=bold guifg=#f7f7d7 guibg=#676767 gui=bold
hi HiColor14 ctermfg=194 ctermbg=23  cterm=none guifg=#cff3f3 guibg=#276c37 gui=none

from vim-highlighter.

azabiong avatar azabiong commented on May 26, 2024

I think this is a very interesting idea! 😄 I tried this mapping and it works! 👍

The original design was to use both native search and highlight jumps to enrich search options.

So, how about this one.

While hlsearch is displayed, the 'n' and 'N' keys perform their original functions. When hlsearch is not displayed, for example after running the noh command, the keys would perform jump to highlight functions. For this, I expect it will only require 'n' and 'N' key mappings to a new function, like HiSearch().

What do you think?

from vim-highlighter.

azabiong avatar azabiong commented on May 26, 2024

Now HiSearch() function supports n and N mapping.

nn n  <Cmd>call HiSearch('n')<CR>
nn N  <Cmd>call HiSearch('N')<CR>

And, if there is no key mapping for the :noh command:

nn <Esc>n  <Cmd>noh<CR>

That's it 😄

You can now easily switch between native search and jump mode. When switching to jump mode, you can simply turn off hlsearch using the :noh command.

Now you probably don't need the * key mapping.

from vim-highlighter.

aminroosta avatar aminroosta commented on May 26, 2024

@azabiong You made my day!
I love the fact that HiSearch() now supports n and N mappings 🎉.

" I changed it a bit, and now it's exactly what I wanted.
let HiCursorGuide = 0
let HiSet = '*'
nn n  <Cmd>call HiSearch('n')<CR>
nn N  <Cmd>call HiSearch('N')<CR>
nn ( :nohl<cr>:Hi clear<cr>

from vim-highlighter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.