Mark : a little script to highlight several words in different colors simultaneously
script karma |
Rating 1125/752,
Downloaded by 18447 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Yuheng Xie |
|
script type |
utility |
|
description |
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 a fork development on mark.vim and you may be interest to check it out:
http://www.vim.org/scripts/script.php?script_id=2666
mark.vim continues to be developed in my taste. :-)
Usage:
Highlighting:
Normal mode:
\m mark/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 mute/unmute all highlighted marks
To clear all marks (instead of mute them), please use \m in muted state.
Visual mode:
\m mark/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)
Command line:
:Mark regexp to mark a regular expression
:Mark regexp with exactly the same regexp to unmark it
:Mark to mute all marks
:Mark to show all marks again
Searching:
Normal mode:
* # \* \# \/ \? 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 \/.
Screenshot:
http://elefant.name/files/vim_screenshot.png (1.1.11-g, 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
:colorscheme default
you should
:source PATH_OF_PLUGINS/mark.vim
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. |
|
install details |
Just drop the script file "mark.vim" into the plugin directory. Restart VIM.
Add ! in viminfo if you want marks restorable on next vim start. E.g.:
set viminfo='64,<8192,s1024,!,h
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
source PATH_OF_PLUGINS/mark.vim
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
colorscheme xxxx
set background=dark
run after you have set your colors. It's due to the same reason. |
|
script versions (upload new version)
Click on the package to download.
mark.vim |
1.2.2-g |
2019-01-30 |
6.0 |
Yuheng Xie |
default state to muted when vim restarts, press \n to reshow all marks in last vim session. |
mark.vim |
1.2.1-g |
2019-01-28 |
6.0 |
Yuheng Xie |
fix multi-lines mark searching/unmarking |
mark.vim |
1.2-g |
2019-01-14 |
6.0 |
Yuheng Xie |
1. Instead of clear all marks, \n now simply mutes them, press \n once more to show them again
2. To clear all marks (instead of mute them), press \m (to create a new mark) when muted
3. Marks are now savable if 'viminfo' has the ! flag. E.g. set viminfo='64,<8192,s1024,!,h |
mark.vim |
1.1.13-g |
2019-01-09 |
6.0 |
Yuheng Xie |
fix unnamed-register content after visual marking |
mark.vim |
1.1.12-g |
2017-11-21 |
6.0 |
Yuheng Xie |
fixed errors when no marks found |
mark.vim |
1.1.11-g |
2016-12-17 |
6.0 |
Yuheng Xie |
make compatible with vim 6.4; default mark colors now use 256 color names if available. |
mark.vim |
1.1.10-g |
2015-03-02 |
7.2 |
Yuheng Xie |
This is a small bug fix for 1.1.9-g, reload highlights after :split etc. |
mark.vim |
1.1.9-g |
2014-07-29 |
7.0 |
Yuheng Xie |
added call to VIM 7.1 matchadd(), make highlighting keywords possible |
mark.vim |
1.1.8-g |
2008-04-25 |
7.0 |
Yuheng Xie |
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. |
mark.vim |
1.1.8 |
2006-03-10 |
6.0 |
Yuheng Xie |
Added \* \# \/ \? for the ability of jumping to ANY mark, even when the cursor is not currently over any mark.
|
mark.vim |
1.1.7 |
2005-09-29 |
6.0 |
Yuheng Xie |
bug fix again |
mark.vim |
1.1.5 |
2005-09-19 |
6.0 |
Yuheng Xie |
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 |
mark.vim |
1.1.4 |
2005-05-26 |
6.0 |
Yuheng Xie |
use map-<silent> to avoid echo on the command line |
mark.vim |
1.1.2 |
2005-03-22 |
6.0 |
Yuheng Xie |
\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 |
ip used for rating: 142.132.191.50
|