vimの検索ハイライトテキストをカーソルの下にない検索テキストと比較して異なる色にする方法はありますか?カーソル下のパターンにvimハイライトカラーを変更する方法は?
3
A
答えて
2
私.vimrc
はこのコードを持っています
function! HiInterestingWord(n) " {{{2
" Save our location.
normal! mz
" Yank the current word into the z register.
normal! "zyiw
" Calculate an arbitrary match ID. Hopefully nothing else is using it.
let mid = 77750 + a:n
" Clear existing matches, but don't worry if they don't exist.
"silent! call matchdelete(mid)
try
call matchdelete(mid)
catch 'E803'
" Construct a literal pattern that has to match at boundaries.
let pat = '\V\<' . escape(@z, '\') . '\>'
" Actually match the words.
call matchadd("InterestingWord" . a:n, pat, 1, mid)
endtry
" Move back to our original location.
normal! `z
endfunction
"clear all highlighting
function! ClearAllHi()
for i in range(1,6)
let mid = 77750 + i
silent! call matchdelete(mid)
endfor
endfunction
nnoremap <silent> <leader>0 :call ClearAllHi()<cr>
nnoremap <silent> <leader>1 :call HiInterestingWord(1)<cr>
nnoremap <silent> <leader>2 :call HiInterestingWord(2)<cr>
nnoremap <silent> <leader>3 :call HiInterestingWord(3)<cr>
nnoremap <silent> <leader>4 :call HiInterestingWord(4)<cr>
nnoremap <silent> <leader>5 :call HiInterestingWord(5)<cr>
nnoremap <silent> <leader>6 :call HiInterestingWord(6)<cr>
hi def InterestingWord1 guifg=#000000 ctermfg=16 guibg=#ffa724 ctermbg=214
hi def InterestingWord2 guifg=#000000 ctermfg=16 guibg=#aeee00 ctermbg=154
hi def InterestingWord3 guifg=#000000 ctermfg=16 guibg=#8cffba ctermbg=121
hi def InterestingWord4 guifg=#000000 ctermfg=16 guibg=#b88853 ctermbg=137
hi def InterestingWord5 guifg=#000000 ctermfg=16 guibg=#ff9eb8 ctermbg=211
hi def InterestingWord6 guifg=#000000 ctermfg=16 guibg=#ff2c4b ctermbg=195
"}}}
は、これはあなたが異なる色でカーソル下のハイライトの単語に<leader>
+ 1-6
を押すことができます。強調表示を消去するために2回押します。 (hi def...
の色を変えることができます)コマンド。 <leader>+0
すべてのハイライトをクリアします。
コードをvimrcに入れて試してみてください。
それは次のように動作します。
1
人々はダミアン・コンウェイの話
" Damian Conway's Die Blinkënmatchen: highlight matches
nnoremap <silent> n n:call HLNext(0.1)<cr>
nnoremap <silent> N N:call HLNext(0.1)<cr>
function! HLNext (blinktime)
let target_pat = '\c\%#'[email protected]/
let ring = matchadd('ErrorMsg', target_pat, 101)
redraw
exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
call matchdelete(ring)
redraw
endfunction
しかし、個人的に基づいてsolutionを使用している、私は、このハイライト全体ものの、シンプルなものを好みますライン
"cursorline and it's highlighting
set cursorline
hi CursorLine cterm=NONE ctermbg=NONE ctermfg=green
関連する問題
- 1. Vimでpython #commentのハイライトカラーを変更するには?
- 2. Vim:検索ヒットとクイックフィックス選択のハイライトカラーを変更する方法
- 3. Vimの方法は、カーソルのvimで
- 4. 変更vimのカーソルの形状がライン
- 5. NetBeansのようにVimでカーソル下の変数をハイライト表示
- 6. Vim Plugin:カーソル下のシンボルに従う
- 7. vimで一致するパターンにカーソルを移動するコマンド
- 8. UIButtonsのハイライトカラーを変更する
- 9. コンボボックスアイテムのハイライトカラーを変更するWPF
- 10. テキストボックスのハイライトカラーを変更する
- 11. Vimのショートキーの変更方法は?
- 12. <select>ハイライトカラーを変更する
- 13. Vim:カーソル下のファイルに新しい垂直分割を開く方法
- 14. 異なるモードでvimカーソルの形状を変更するには
- 15. Visual Studio 2012 RCでブレークポイント行のハイライトカラーを変更/無効にする方法?
- 16. vim:カーソルとコードの間のスペースを削除する方法は?
- 17. Vim、カーソルをすぐに一様に移動する方法
- 18. Autohotkey |カーソルを下に移動する速度を変更する
- 19. Vimのカーソル下の単語を検索して置換する
- 20. JavafXでカーソルを円に変更する方法は?
- 21. Eclipse:入力ポップアップの選択項目のハイライトカラーを変更する方法
- 22. カーソルを一番下に動かすとvimを自動的にスクロールさせる方法は?
- 23. vimのデフォルトモードを変更する方法はありますか
- 24. EditTextでカーソルの外観を変更する方法は?
- 25. ボタンのカーソルを変更する方法は?
- 26. 特定の場所でカーソルを変更する方法は?
- 27. vimでmatchadd()で使用するために私自身のハイライトカラーを定義する方法は?
- 28. セシウムのカーソルを変更するには?
- 29. 挿入モードのときのVim変更ブロックのカーソル
- 30. vim-snipmateの終了カーソル位置の変更
私はそれがOPが求めているとは思わない:彼は基本的に 'Search'に加えて別々の' SearchCurrent'ハイライトグループを望んでいる。 –