sponsor Vim development Vim logo Vim Book Ad

SelX : A Rainbow of Vim selection/highlighting & search

 script karma  Rating 7/3, Downloaded by 690  Comments, bugs, improvements  Vim wiki

created by
Richard Bentley-Green
script type

SelX provides additional selection/highlighting/search functions that operate in a very similar way to the standard '*' (and similar) key mappings and the standard '/' (and similar) command line search operations; the difference is that multiple, multi-coloured highlights are supported, operating on a per-tab basis

The selection/highlight selections can also (optionally) be saved as part of a vim session. This is also supported by my SessX plugin - vimscript #5874

SelX is intended to complement rather then replace the standard vim selection/search highlight facility

NOTE: This may well work for vim versions prior to 7 - I haven't tried it though

*** If you have any suggestions for improving this, then please let me know. If you think it's rubbish then PLEASE let me know why - it's far more useful than just 'voting it down' (which really doesn't help at all). Contact details are in the top of the README file ***


In order to keep track of which selections/highlights are set, a Highlight Usage Map is automatically displayed on the in-focus window's status line. This Highlight Usage Map looks something like the following;-

  [ 1 | 2 | 3 |   |   | 6 |^  |   |   ]

The Map has an entry for each of the available SelX highlight colours (in reality, the map entries are appropriately coloured)

If a particular highlight is not set then it is shown with just its colour (for example, numbers 4 and 5)

If a particular highlight is set then it is shown with its number (for example, numbers 1, 2 and 3)

The '^' is always displayed and points to the next highlight that will be used when the auto-selection command is used

Markers are also placed (not shown in the above drawing - see the README) to show whether a selection/highlight is a whole word or arbitrary, and whether or not it is case-sensitive. The case-sensitivity can be set prior to the selection and both of these attributes can be toggled after a selection has been made


There are several mappings/commands for selecting/highlighting and searching for a specific selection which mirror the normal '*' (and other) mappings and command line '/' and '?' commands

There are also some optional mappings that enhance (depending on your point of view) the standard vim highlight/search operation
install details
Un-tar into ~/.vim/bundle/ as usual and read the README file for setup and config options

Note that there is some initial setup required to integrate this into your vim installation

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
selx.tar.gz 15/06/21 2021-06-15 7.0 Richard Bentley-Green - Oops! Fixed incorrect command-line feedback/reporting of case toggle mapping
  '<Leader>cH' (the actual operation is/was correct)
selx.tar.gz 04/06/21 2021-06-04 7.0 Richard Bentley-Green - Added commands to copy and paste highlight config between tabs
- Improved feedback text on command line for some commands/mappings
selx.tar.gz 01/03/21 2021-03-02 7.0 Richard Bentley-Green - README/help text improvements
- Changed the characters displayed in the Unicode version of the 'whole word' and 'case-insensitive' markers to something a bit more subtle (smaller)
selx.tar.gz 27/02/21 2021-02-28 7.0 Richard Bentley-Green - Some minor improvements to this README and documentation
- Added support for case selection/toggling, inc new mappings toggling case-sensitivity, both default and per-selection - see the new mappings <Leader>C and <Leader>cH
- Highlight Selection Map now shows markers to indicate word/arbitrary selection and case-sensitivity for each highlight - see README for details
selx.tar.gz 24/11/20 2020-11-25 7.0 Richard Bentley-Green - Improved feedback for 'full word/arbitrary' selection toggle operation
- Added search success/failure feedback; printed to command line
- Minor comment corrections
selx.tar.gz 27/10/2020 2020-11-21 7.0 Richard Bentley-Green - Modified visual selection version of '*' so that it does not immediately jump to next occurrence; ie - works like the 'normal' version
- Modified list of suggested highlight colours
selx.tar.gz 01/05/20 2020-05-01 7.0 Richard Bentley-Green Added :SelXList command to print details of active selections/highlights
selx.tar.gz 27/04/20 2020-04-28 7.0 Richard Bentley-Green Added 'default' to setting StatusMsg colour. Without this, colour override would be hit-and-miss
Removed a stray mapping for '*' from autoload/selx.vim - oops!
selx.tar.gz 26/04/20 2020-04-27 7.0 Richard Bentley-Green Documentation improvements.
Minor functional changes - nothing serious, but worth having
See version information at bottom of README for full details
selx.tar.gz 25/04/20 2020-04-25 7.0 Richard Bentley-Green Documentation improvements. Improved control over mappings. Corrected one use of 'normal' to 'normal!'
ip used for rating:

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.