Comments (5)
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.
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.
I think this is a very interesting idea!
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.
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.
@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)
- Images
- Clear all when cursor is not on any highlight HOT 7
- Feature Request: Send highlights to quickfix/loclist HOT 10
- install instructions HOT 1
- autoload highlight after split window HOT 1
- Error while creating a highlighting while selecting a single line with visual line mode HOT 3
- Feature Request: add support for line-pattern (\%l) HOT 5
- Getting No such group or event error HOT 2
- Unable to save when whitespaces in the path HOT 2
- whole words & ignore case HOT 1
- No such group or event: ColorSchemePre * call highlighter#ColorScheme('pre') after installing HOT 6
- Visual Mode remap HOT 2
- Feature request: replacement HOT 6
- Error detected while using highlighter.vim HOT 1
- How to re-order colors HOT 3
- Add highlight programmaticaly HOT 8
- [Question] How to navigate highlighters in current buffer? HOT 10
- Can't highlight a single character HOT 24
- [Question] The highlight's color was different from two window. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-highlighter.