sponsor Vim development Vim logo Vim Book Ad

simple_highlighting : Easily highlight multiple words in all buffers and search through them

 script karma  Rating 20/5, Downloaded by 336    Comments, bugs, improvements  Vim wiki

created by
Pev Hall
 
script type
utility
 
description
Script is designed to be easy and quick to use and satisfy the following functionality:
1. Highlight multiple different words in multiple different highlighting styles.
2. Keep the highlights between buffers.
3. Change search pattern to a highlighted style

Brief example of usage:
  * Place your cursor on a word and use \h to highlight it.
  * Run "\h" while cursor over another word will add it to the default (0) highlight slot.
  * Run "\h" on a word already in the default (0) highlight slot to remove it
  * 2\h will highlight a new word in 2 highlight slot.
  * Change buffer or open new window and highlights will remain the same
  * ":Hc 2"  will clear all the of slots 2's highlights.
  * ":Hs"     to changes the search pattern to all the current highlighted word
  * ":Hc"     will clear all highlights.
  * ":Ha 1 \<aa" will add the regular expression "\<aa" to highlight slot 1

------------------------------------------------------------------------------------------------------------
Detailed description of use:

<leader> default is \

[<number>] <Leader> h   -> to highlight the whole word under the cursor, highlighted colour is determined by the preceding number, if no number is given 0 is used

numbers can be between 0 to 7 default is 0. More highlight numbers/slots can be added and there representative colour's changed at the start of the script.

:Hc [0 2 ...] <return>
-> HighlightClear: clears the highlighted patterns listed or all if no number(s) passed

:Hs [0 2 ...] <return>
-> HighlightSearch: changes the search pattern to the highlighted patterns listed or all if no number(s) passed

:Ha <slot number> <pattern> [additional patterns ...] <return>
-> HighlightAddMultiple: adds the pattern and any additional patterns (space separated) to the highlight slot specified in <slot number>. The patterns support regular expressions

If the word/pattern you are trying to highlight already exits in a slot it will be removed from the previous slot. If the previous slot is the same as the one new one (you are trying to add it to the same slot twice) it will simply remove the word/pattern.

------------------------------------------------------------------------------------------------------------

No known bugs.

<http://vim.wikia.com/wiki/Highlight_multiple_words > is a very good alternative to this script. This script is designed to be simple and easy to use

<http://www.vim.org/scripts/script.php?script_id=2666 > is a much more compressive and complex script then this one.
 
install details
Copy contents of script and past into your _vimrc/.vimrc file.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
simpleHighlightingV1.1.vimrc 1.1.0 2014-08-28 7.2 Pev Hall Fixed issue when using commands with multiple numbers eg
    :Hs 0 2

Two major improvements:
   * If you highlight a word (or pattern) in a highlight slot where the word/pattern already exists. It now removes the highlight (so you don't have to clear all the highlights in the slot). If it exits in a different slot it will remove it from the old slot before putting it in the new.

   * Added new command "Ha" (Highlight add) so it is much easier to add highlights that use regular expressions. See description for more information
simple_highlighting.vimrc 1.0.0 2013-12-17 7.2 Pev Hall Major fix: Removed conflicts when multiple windows are editing same buffer.
simple_highlighting 0.9.1 2013-08-11 7.2 Pev Hall Missed some dependent functions in previous commit.
ip used for rating: 54.87.89.176

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo