Mark : a little script to highlight several words in different colors simultaneously
| script karma
Downloaded by 11226
Comments, bugs, improvements
script versions (upload new version)
|This script is written to highlight several words in different colors simultaneously. For example, when you are browsing a big program file, you could highlight some key variables. This will make it easier to trace the source code.
I found Ingo Karkat has some further development on mark.vim and you may be interest to check it out:
mark.vim 1.1.9-g version fanally uses VIM's matchadd(), now highlighting keywords is possible.
\m mark or unmark the word under (or before) the cursor
Place the cursor under the word to be highlighted, press \m, then the word will be colored.
\r manually input a regular expression
To highlight an arbitrary regular expression, press \r and input the regexp.
\n clear this mark (i.e. the mark under the cursor), or clear all highlighted marks
\m mark or unmark a visual selection
Select some text in Visual mode, press \m, then the selection will be colored.
\r manually input a regular expression (base on the selection text)
:Mark regexp to mark a regular expression
:Mark regexp with exactly the same regexp to unmark it
:Mark to clear all marks
* # \* \# \/ \? use these six keys to jump to the other marks
and you could also use VIM's / and ? to search, since the mark patterns have
been added to the search history.
Here is a sumerization of * # \* \# \/ \?:
" First of all, \#, \? and # behave just like \*, \/ and *, respectively,
" except that \#, \? and # search backward.
" \*, \/ and *'s behaviors differ base on whether the cursor is currently
" placed over an active mark:
" Cursor over mark Cursor not over mark
" \* jump to the next occurrence of jump to the next occurrence of
" current mark, and remember it "last mark".
" as "last mark".
" \/ jump to the next occurrence of same as left
" ANY mark.
" * if \* is the most recently used, do VIM's original *
" do a \*; otherwise (\/ is the
" most recently used), do a \/.
http://elefant.name/files/vim_screenshot.png (It is also the screenshot of my colorscheme vimscript #1253.)
Bugs and Notes:
Some words which have been already colored by syntax scripts could not be highlighted in VIM 7.0 or before. Please upgrade your VIM to a newer version.
mark.vim should be re-sourced after any changing to colors. For example, if you
:set background=dark OR
after that. Otherwise, you won't see the colors.
Unfortunately, it seems that .gvimrc runs after plugin scripts. So if you set any color settings in .gvimrc, you have to add one line to the end of .gvimrc to source mark.vim.
|Just drop the script file "mark.vim" into the plugin directory. Restart VIM.
If you want to use another leader instead of default "\", you may say in your .vimrc
let mapleader = ","
That will use ,m ,r ,n instead of \m \r \n as the trigger.
If you set any color settings in .gvimrc, you should also add
to the end of .gvimrc (see above).
If you want different colors or more colors, you may define MarkWord1-6, 7, 8...
in your vimrc file. Just to pay attention that there should be no lines like
run after you have set your colors. It's due to the same reason.
Click on the package to download.
ip used for rating: 220.127.116.11
||This is a small bug fix for 1.1.9-g, reload highlights after :split etc.
||added call to VIM 7.1 matchadd(), make highlighting keywords possible
||1.1.8 global version. It differ from 1.1.8 that colors will be shared between buffers, instead of localized to buffers as in 1.1.8.
If you would like to have the same words highlighted in different files, use this.
If you would like to have different words highlighted in different files, use 1.1.8.
||Added \* \# \/ \? for the ability of jumping to ANY mark, even when the cursor is not currently over any mark.
||bug fix again
||Thank Luc Hermitte for the big improvement to my script:
1) now can use :Mark to trigger the function.
2) \r on visual mode to input a regexp base on the selection
3) may alter the leader (instead of default "\") in .vimrc
||use map-<silent> to avoid echo on the command line
||\n now first try to clear this mark (i.e. the mark under the cursor), before clearing all marks.
mapped * and # for jumping to the next and previous occurrence of this mark.
mark patterns now also added to the search history