Giter Club home page Giter Club logo

vim-mark's Introduction

MARK

by Ingo Karkat (original version by Yuheng Xie)

DESCRIPTION

This plugin adds mappings and a :Mark command to highlight several words in different colors simultaneously, similar to the built-in 'hlsearch' highlighting of search results and the * star command. For example, when you are browsing a big program file, you could highlight multiple identifiers in parallel. This will make it easier to trace the source code.

This is a continuation of vimscript #1238 by Yuheng Xie, who doesn't maintain his original version anymore and recommends switching to this fork. This plugin offers the following advantages over the original:

  • Much faster, all colored words can now be highlighted, no more clashes with syntax highlighting (due to use of matchadd()).
  • Many bug fixes.
  • Jumps behave like the built-in search, including wrap and error messages.
  • Like the built-in commands, jumps take an optional [count] to quickly skip over some marks.
  • Marks can be persisted, and patterns can be added / subtracted from mark highlight groups.

SEE ALSO

  • SearchAlternatives.vim (vimscript #4146) provides mappings and commands to add and subtract alternative branches to the current search pattern.
  • SearchHighlighting.vim (vimscript #4320) can change the semantics of the start command *, extends it to visual mode (like Mark) and has auto-search functionality which instantly highlights the word under the cursor when typing or moving around, like in many IDEs.
  • MarkMarkup.vim (vimscript #5777) extends mark.vim with rendering the highlightings as markup directly inside the text: as HTML <span> tags that reproduce the mark's colors, or as appended numbers or symbols and a legend to look up the mark names. Any markup-based export format can be defined.

RELATED WORKS

  • MultipleSearch (vimscript #479) can highlight in a single window and in all buffers, but still relies on the :syntax highlighting method, which is slower and less reliable.
  • http://vim.wikia.com/wiki/Highlight_multiple_words offers control over the color used by mapping the 1-9 keys on the numeric keypad, persistence, and highlights only a single window.
  • highlight.vim (vimscript #1599) highlights lines or patterns of interest in different colors, using mappings that start with CTRL-H and work on cword.
  • quickhl.vim (vimscript #3692) can also list the matches with colors and in addition offers on-the-fly highlighting of the current word (like many IDEs do).
  • Highlight (http://www.drchip.org/astronaut/vim/index.html#HIGHLIGHT) has commands and mappings for highlighting and searching, uses matchadd(), but limits the scope of highlightings to the current window.
  • TempKeyword (vimscript #4636) is a simple plugin that can matchadd() the word under the cursor with \0 - \9 mappings. (And clear with \c0 etc.)
  • simple_highlighting (vimscript #4688) has commands and mappings to highlight 8 different slots in all buffers.
  • searchmatch (vimscript #4869) has commands and mappings for :[1,2,3]match, in the current window only.
  • highlight-groups.vim (vimscript #5612) can do buffer-local as well as tab-scoped highlighting via :syntax, and has multiple groups whose highlighting is defined in an external CSV file.
  • Syntax match (vimscript #5376) provides various (color-based) shortcut commands for :syntax match, and saves and restores those definitions, for text and log files.
  • SelX (vimscript #5875) provides multiple multi-colored highlights per-tab (that can be stored in a session), mappings that mirror the built-in search commands, as a special feature automatically displays a Highlight Usage Map.
  • hi (vimscript #5887) highlights words, sentences or regular expressions using many configured colors, and can search; also offers separate windows for filtering and configuration editing catered towards log analysis.
  • vim-highlight-hero (vimscript #5922) can also highlight the current word or selection, has some flexibility with regard to whitespace matching, is limited to the current window.

USAGE

HIGHLIGHTING

<Leader>m               Mark the word under the cursor, similar to the star
                        command. The next free highlight group is used.
                        If already on a mark: Clear the mark, like
                        <Leader>n.
{Visual}<Leader>m       Mark or unmark the visual selection.
{N}<Leader>m            With {N}, mark the word under the cursor with the
                        named highlight group {N}. When that group is not
                        empty, the word is added as an alternative match, so
                        you can highlight multiple words with the same color.
                        When the word is already contained in the list of
                        alternatives, it is removed.

                        When {N} is greater than the number of defined mark
                        groups, a summary of marks is printed. Active mark
                        groups are prefixed with "*" (or "M*" when there are
                        M pattern alternatives), the default next group with
                        ">", the last used search with "/" (like :Marks
                        does). Input the mark group, accept the default with
                        <CR>, or abort with <Esc> or any other key.
                        This way, when unsure about which number represents
                        which color, just use 99<Leader>n and pick the color
                        interactively!

{Visual}[N]<Leader>m    Ditto, based on the visual selection.

[N]<Leader>r            Manually input a regular expression to mark.
{Visual}[N]<Leader>r    Ditto, based on the visual selection.

                        In accordance with the built-in star command,
                        all these mappings use 'ignorecase', but not
                        'smartcase'.

<Leader>n               Clear the mark under the cursor.
                        If not on a mark: Disable all marks, similar to
                        :nohlsearch.
                        Note: Marks that span multiple lines are not detected,
                        so the use of <Leader>n on such a mark will
                        unintentionally disable all marks! Use
                        {Visual}<Leader>r or :Mark {pattern} to clear
                        multi-line marks (or pass [N] if you happen to know
                        the group number).
{N}<Leader>n            Clear the marks represented by highlight group {N}.

:{N}Mark                Clear the marks represented by highlight group {N}.
:[N]Mark[!] [/]{pattern}[/]
                        Mark or unmark {pattern}. Unless [N] is given, the
                        next free highlight group is used for marking.
                        With [N], mark {pattern} with the named highlight
                        group [N]. When that group is not empty, the word is
                        added as an alternative match, so you can highlight
                        multiple words with the same color, unless [!] is
                        given; then, {pattern} overrides the existing mark.
                        When the word is already contained in the list of
                        alternatives, it is removed.
                        For implementation reasons, {pattern} cannot use the
                        'smartcase' setting, only 'ignorecase'.
                        Without [/], only literal whole words are matched.
                        :search-args
:Mark                   Disable all marks, similar to :nohlsearch. Marks
                        will automatically re-enable when a mark is added or
                        removed, or a search for marks is performed.

:MarkClear              Clear all marks. In contrast to disabling marks, the
                        actual mark information is cleared, the next mark will
                        use the first highlight group. This cannot be undone.

:[N]Mark[!] /{pattern}/ as [name]
                        Mark or unmark {pattern}, and give it [name].
:{N}MarkName [name]
                        Give [name] to mark group {N}.
:MarkName!              Clear names for all mark groups.

SEARCHING

[count]*         [count]#
[count]<Leader>* [count]<Leader>#
[count]<Leader>/ [count]<Leader>?
                        Use these six keys to jump to the [count]'th next /
                        previous occurrence of a mark.
                        You could also use Vim's / and ? to search, since the
                        mark patterns are (optionally, see configuration)
                        added to the search history, too.

            Cursor over mark                    Cursor not over mark
 ---------------------------------------------------------------------------
  <Leader>* Jump to the next occurrence of      Jump to the next occurrence of
            current mark, and remember it       "last mark".
            as "last mark".

  <Leader>/ Jump to the next occurrence of      Same as left.
            ANY mark.

   *        If <Leader>* is the most recently   Do Vim's original * command.
            used, do a <Leader>*; otherwise
            (<Leader>/ is the most recently
            used), do a <Leader>/.

                        Note: When the cursor is on a mark, the backwards
                        search does not jump to the beginning of the current
                        mark (like the built-in search), but to the previous
                        mark. The entire mark text is treated as one entity.

                        You can use Vim's jumplist to go back to previous
                        mark matches and the position before a mark search.

If you work with multiple highlight groups and assign special meaning to them
(e.g. group 1 for notable functions, 2 for variables, 3 for includes), you can
use the 1-9 keys on the numerical keypad to jump to occurrences of a
particular highlight group. With the general * and # commands above, you'd
first need to locate a nearby occurrence of the desired highlight group if
it's not the last mark used.

<k1> .. <k9>            Jump to the [count]'th next occurrence of the mark
                        belonging to highlight group 1..9.
<C-k1> .. <C-k9>        Jump to the [count]'th previous occurrence of the mark
                        belonging to highlight group 1..9.
                        Note that these commands only work in GVIM or if your
                        terminal sends different key codes; sadly, most still
                        don't.
                        https://unix.stackexchange.com/questions/552297/make-gnome-terminal-send-correct-numeric-keypad-keycodes-to-vim
                        The "Num Lock" indicator of your keyboard has
                        to be ON; otherwise, the keypad is used for cursor
                        movement. If the keypad doesn't work for you, you can
                        still remap these mappings to alternatives; see below.
Alternatively, you can set up mappings to search in a next / previous used
group, see mark-group-cycle.

[...]
After a stop, retriggering the cascaded search in the same buffer and window
moves to the next used group (you can jump inside the current buffer to choose
a different starting point first). If you instead switch to another window or
buffer, the current mark group continues to be searched (to allow you to
keep searching for the current group in other locations, until those are all
exhausted too).

MARK PERSISTENCE

The marks can be kept and restored across Vim sessions, using the viminfo
file. For this to work, the "!" flag must be part of the 'viminfo' setting:
    set viminfo^=!  " Save and restore global variables.

:MarkLoad               Restore the marks from the previous Vim session. All
                        current marks are discarded.
:MarkLoad {slot}        Restore the marks stored in the named {slot}. All
                        current marks are discarded.

:MarkSave               Save the currently defined marks (or clear the
                        persisted marks if no marks are currently defined) for
                        use in a future Vim session.
:MarkSave {slot}        Save the currently defined marks in the named {slot}.
                        If {slot} is all UPPERCASE, the marks are persisted
                        and can be |:MarkLoad|ed in a future Vim session (to
                        persist without closing Vim, use :wviminfo; an
                        already running Vim session can import marks via
                        :rviminfo followed by :MarkLoad).
                        If {slot} contains lowercase letters, you can just
                        recall within the current session. When no marks are
                        currently defined, the {slot} is cleared.

By default, automatic persistence is enabled (so you don't need to explicitly
:MarkSave), but you have to explicitly load the persisted marks in a new Vim
session via :MarkLoad, to avoid that you accidentally drag along outdated
highlightings from Vim session to session, and be surprised by the arbitrary
highlight groups and occasional appearance of forgotten marks. If you want
just that though and automatically restore any marks, set g:mwAutoLoadMarks.

You can also initialize some marks (even using particular highlight groups) to
static values, e.g. by including this in vimrc:
    runtime plugin/mark.vim
    silent MarkClear
    silent 5Mark foo
    silent 6Mark /bar/
Or you can define custom commands that preset certain marks:
    command -bar MyMarks exe '5Mark! foo' | exe '6Mark! /bar/'
Or a command that adds to the existing marks and then toggles them:
    command -bar ToggleFooBarMarks exe 'Mark foo' | exe 'Mark /bar/'
The following commands help with setting these up:

:MarkYankDefinitions [x]
                        Place definitions for all current marks into the
                        default register / [x], like this:
                            1Mark! /\<foo\>/
                            2Mark! /bar/
                            9Mark! /quux/
:MarkYankDefinitionsOneLiner [x]
                        Like :MarkYankDefinitions, but place all definitions
                        into a single line, like this:
                        exe '1Mark! /\<foo\>/' | exe '2Mark! /bar/' | exe '9Mark! /quux/'
Alternatively, the mark#GetDefinitionCommands(isOneLiner) function can be used
to obtain a List of :Mark commands instead of using a register. With that,
you could for example build a custom alternative to :MarkSave that stores
Marks in separate files (using writefile(), read by :source or even
automatically via a local vimrc plugin) instead of the viminfo file.

MARK INFORMATION

Both mark-highlighting and mark-searching commands print information about
the mark and search pattern, e.g.
        mark-1/\<pattern\>
This is especially useful when you want to add or subtract patterns to a mark
highlight group via [N].

:Marks                  List all mark highlight groups and the search patterns
                        defined for them.
                        The group that will be used for the next :Mark or
                        <Leader>m command (with [N]) is shown with a ">".
                        The last mark used for a search (via <Leader>*) is
                        shown with a "/".

MARK HIGHLIGHTING PALETTES

The plugin comes with three predefined palettes: original, extended, and
maximum. You can dynamically toggle between them, e.g. when you need more
marks or a different set of colors.

:MarkPalette {palette}  Highlight existing and future marks with the colors
                        defined in {palette}. If the new palette contains less
                        mark groups than the current one, the additional marks
                        are lost.
                        You can use :command-completion for {palette}.

See g:mwDefaultHighlightingPalette for how to change the default palette,
and mark-palette-define for how to add your own custom palettes.

INSTALLATION

The code is hosted in a Git repo at https://github.com/inkarkat/vim-mark You can use your favorite plugin manager, or "git clone" into a directory used for Vim packages. Releases are on the "stable" branch, the latest unstable development snapshot on "master".

This script is also packaged as a vimball. If you have the "gunzip" decompressor in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress the archive first, e.g. using WinZip. Inside Vim, install by sourcing the vimball or via the :UseVimball command.

vim mark*.vmb.gz
:so %

To uninstall, use the :RmVimball command.

DEPENDENCIES

  • Requires Vim 7.1 with matchadd(), or Vim 7.2 or higher.
  • Requires the ingo-library.vim plugin (vimscript #4433), version 1.043 or higher.

CONFIGURATION

For a permanent configuration, put the following commands into your vimrc.

This plugin defines 6 mark groups:

    1: Cyan  2:Green  3:Yellow  4:Red  5:Magenta  6:Blue

Higher numbers always take precedence and are displayed above lower ones.

Especially if you use GVIM, you can switch to a richer palette of up to 18 colors:

let g:mwDefaultHighlightingPalette = 'extended'

Or, if you have both good eyes and display, you can try a palette that defines 27, 58, or even 77 colors, depending on the number of available colors:

let g:mwDefaultHighlightingPalette = 'maximum'

Note: This only works for built-in palettes and those that you define prior to running the plugin. If you extend the built-ins after plugin initialization (mark-palette-define), use :MarkPalette instead.

If you like the additional colors, but don't need that many of them, restrict their number via:

    let g:mwDefaultHighlightingNum = 9

If none of the default highlightings suits you, define your own colors in your vimrc file (or anywhere before this plugin is sourced, but after any :colorscheme), in the following form (where N = 1..):

highlight MarkWordN ctermbg=Cyan ctermfg=Black guibg=#8CCBEA guifg=Black

You can also use this form to redefine only some of the default highlightings. If you want to avoid losing the highlightings on :colorscheme commands, you need to re-apply your highlights on the ColorScheme event, similar to how this plugin does. Or you define the palette not via :highlight commands, but use the plugin's infrastructure:

let g:mwDefaultHighlightingPalette = [
\   { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#8CCBEA', 'guifg':'Black' },
\   ...
\]

If you want to switch multiple palettes during runtime, you need to define them as proper palettes. a) To add your palette to the existing ones, do this after the default palette has been defined (e.g. in ~/.vim/after/plugin/mark.vim):

if ! exists('g:mwPalettes') " (Optional) guard if the plugin isn't properly installed.
    finish
endif

let g:mwPalettes['mypalette'] = [
\   { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#8CCBEA', 'guifg':'Black' },
\   ...
\]
let g:mwPalettes['other'] = [ ... ]

" Make it the default; you cannot use g:mwDefaultHighlightingPalette
here, as the Mark plugin has already been initialized:
MarkPalette mypalette

b) Alternatively, you can completely override all built-in palettes in your vimrc:

let g:mwPalettes = {
\   'mypalette': [
\       { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#8CCBEA', 'guifg':'Black' },
\       ...
\   ]
\}

" Make it the default:
let g:mwDefaultHighlightingPalette = 'mypalette'

The search type highlighting (in the search message) can be changed via:

highlight link SearchSpecialSearchType MoreMsg

By default, any marked words are also added to the search (/) and input (@) history; if you don't want that, remove the corresponding symbols from:

let g:mwHistAdd = '/@'

To enable the automatic restore of marks from a previous Vim session:

let g:mwAutoLoadMarks = 1

To turn off the automatic persistence of marks across Vim sessions:

let g:mwAutoSaveMarks = 0

You can still explicitly save marks via :MarkSave.

If you have set 'ignorecase', but want marks to be case-insensitive, you can override the default behavior of using 'ignorecase' by setting:

    let g:mwIgnoreCase = 0

To exclude some tab pages, windows, or buffers / filetypes from showing mark highlightings (you can still "blindly" navigate to marks in there with the corresponding mappings), you can define a List of expressions or Funcrefs that are evaluated in every window; if one returns 1, the window will not show marks.

" Don't mark temp files, Python filetype, and scratch files as defined by
" a custom function.
let g:mwExclusionPredicates =
\   ['expand("%:p") =~# "/tmp"', '&filetype == "python", function('ExcludeScratchFiles')]

By default, tab pages / windows / buffers that have t:nomarks / w:nomarks / b:nomarks with a true value are excluded. Therefore, to suppress mark highlighting in a buffer, you can simply

:let b:nomarks = 1

If the predicate changes after a window has already been visible, you can update the mark highlighting by either:

  • switching tab pages back and forth
  • toggling marks on / off (via <Plug>MarkToggle)
  • :call mark#UpdateMark() (for current buffer)
  • :call mark#UpdateScope() (for all windows in the current tab page)

This plugin uses matchadd() for the highlightings. Each mark group has its own priority, with higher group values having higher priority; i.e. going "on top". The maximum priority (used for the last defined mark group) can be changed via:

let g:mwMaxMatchPriority = -10

For example when another plugin or customization also uses matches and you would like to change their relative priorities. The default is negative to step back behind the default search highlighting.

If you want no or only a few of the available mappings, you can completely turn off the creation of the default mappings by defining:

:let g:mw_no_mappings = 1

This saves you from mapping dummy keys to all unwanted mapping targets.

You can use different mappings by mapping to the <Plug>Mark... mappings (use ":map <Plug>Mark" to list them all) before this plugin is sourced.

There are no default mappings for toggling all marks and for the :MarkClear command, but you can define some yourself:

nmap <Leader>M <Plug>MarkToggle
nmap <Leader>N <Plug>MarkAllClear

As the latter is irreversible, there's also an alternative with an additional confirmation:

nmap <Leader>N <Plug>MarkConfirmAllClear

To remove the default overriding of * and #, use:

nmap <Plug>IgnoreMarkSearchNext <Plug>MarkSearchNext
nmap <Plug>IgnoreMarkSearchPrev <Plug>MarkSearchPrev

If you don't want the * and # mappings remember the last search type and instead always search for the next occurrence of the current mark, with a fallback to Vim's original * command, use:

nmap * <Plug>MarkSearchOrCurNext
nmap # <Plug>MarkSearchOrCurPrev

Or for search for the next occurrence of any mark with fallback to *:

nmap * <Plug>MarkSearchOrAnyNext
nmap # <Plug>MarkSearchOrAnyPrev

Mark searches could also be combined with the built-in search. This mapping overloads the default n|/|N commands to search for any mark if there is any mark defined and marks are enabled, and fall back to the default search if not:

nmap n <Plug>MarkSearchAnyOrDefaultNext
nmap N <Plug>MarkSearchAnyOrDefaultPrev

The search mappings (*, #, etc.) interpret [count] as the number of occurrences to jump over. If you don't want to use the separate mark-keypad-searching mappings, and rather want [count] select the highlight group to target (and you can live with jumps restricted to the very next match), (re-)define to these mapping targets:

nmap * <Plug>MarkSearchGroupNext
nmap # <Plug>MarkSearchGroupPrev

You can remap the direct group searches (by default via the keypad 1-9 keys):

nmap <Leader>1  <Plug>MarkSearchGroup1Next
nmap <Leader>!  <Plug>MarkSearchGroup1Prev

If you need more / less groups, this can be configured via:

let g:mwDirectGroupJumpMappingNum = 20

Set to 0 to completely turn off the keypad mappings. This is easier than remapping all <Plug>-mappings.

As an alternative to the direct group searches, you can also define mappings that search a next / previous used group:

nmap <Leader>+* <Plug>MarkSearchUsedGroupNext
nmap <Leader>-* <Plug>MarkSearchUsedGroupPrev

Some people like to create a mark based on the visual selection, like v_<Leader>m, but have whitespace in the selection match any whitespace when searching (searching for "hello world" will also find "hello<Tab>world" as well as "hello" at the end of a line, with "world" at the start of the next line). The Vim Tips Wiki describes such a setup for the built-in search at http://vim.wikia.com/wiki/Search_for_visually_selected_text You can achieve the same with the Mark plugin through the <Plug>MarkIWhiteSet mapping target: Using this, you can assign a new visual mode mapping <Leader>*

xmap <Leader>* <Plug>MarkIWhiteSet

or override the default v_<Leader>m mapping, in case you always want this behavior:

vmap <Plug>IgnoreMarkSet <Plug>MarkSet
xmap <Leader>m <Plug>MarkIWhiteSet

INTEGRATION

The following functions offer (read-only) access to the script's internals:

  • mark#GetGroupNum(): number of available groups
  • mark#GetCount(): number of defined marks
  • mark#GetPattern([{index}]): search regular expression for an individual mark
  • mark#GetMarkNumber({pattern}, {isLiteral}, {isConsiderAlternatives}): mark number of a pattern / literal text

LIMITATIONS

  • If the 'ignorecase' setting is changed, there will be discrepancies between the highlighted marks and subsequent jumps to marks.
  • If {pattern} in a :Mark command contains atoms that change the semantics of the entire (/\c, /\C) regular expression, there may be discrepancies between the highlighted marks and subsequent jumps to marks.

CONTRIBUTING

Report any bugs, send patches, or suggest features via the issue tracker at https://github.com/inkarkat/vim-mark/issues or email (address below).

HISTORY

3.2.1 RELEASEME
  • Expose mark#mark#AnyMarkPattern().
  • Robustness: Place the ColorScheme initialization also in the MarkInitialization autocommand group.
3.2.0 15-Feb-2022
  • Add mark#GetMarkNumber(), based on feedback by Snorch in #36.
  • Mark updates across windows now use win_execute() (since Vim 8.1.1418) instead of :windo. This hopefully addresses the changes in window sizes that have been reported (e.g. in #34).
  • Add <Plug>MarkSearchAnyOrDefaultNext and <Plug>MarkSearchAnyOrDefaultPrev for an any-mark search with fallback to the built-in search pattern. Suggested by Denis Kasak.

You need to update to ingo-library (vimscript #4433) version 1.043!

3.1.1 03-Aug-2020
  • Compatibility: After Vim 8.1.1241, a :range outside the number of buffers (e.g. :99Mark[Name]) causes an error.
  • ENH: Add (GUI-only) additional palettes "soft" and "softer" that are variants of "extended" with less saturation / higher brightness of background colors (for when the default colors are too distracting).
  • ENH: Marks that cover multiple lines (created through a visual selection or :Mark /{pattern}/) now also can be jumped to when the cursor is not on the mark's first line.

You need to update to ingo-library (vimscript #4433) version 1.042!

3.1.0 23-Mar-2019
  • ENH: Handle magicness atoms (\V, \m) in regexps entered via <Leader>r or :Mark /{pattern}/.
  • ENH: Choose a more correct insertion point with multiple alternatives for a mark by projecting the length of the existing and alternatives and the added pattern.
  • BUG: Regression: <Leader>n without {N} and not on an existing mark prints error "Do not pass empty pattern to disable all marks".
  • ENH: Allow to exclude certain tab pages, windows, or buffers / filetypes from showing mark highlightings via g:mwExclusionPredicates or (with the default predicate) t:nomarks / w:nomarks / b:nomarks flags.
  • ENH: Allow to tweak the maximum match priority via g:mwMaxMatchPriority for better coexistence with other customizations that use :match / matchadd().
  • ENH: Allow to disable all default mappings via a single g:mw_no_mappings configuration flag.
  • ENH: Appended (strong) green and yellow highlightings to the extended palette.
  • Refactoring: Move mark persistence implementation to ingo-library. No need to serialize into String type for viminfo beyond Vim 7.3.030.
  • BUG: Avoid creating jump when updating marks. Need to use :keepjumps windo. Reported by epheien.

You need to update to ingo-library (vimscript #4433) version 1.036!

3.0.0 18-Sep-2017
  • CHG: Parse :Mark arguments as either /{pattern}/ or whole {word}. This better addresses the common use case of searching for whole words, and is consistent with built-in commands like :djump.
  • ENH: Keep previous (last accessed) window on :windo.
  • Consistently use :noautocmd during window iteration.
  • ENH: Add :MarkYankDefinitions and :MarkYankDefinitionsOneLiner commands. These make it easier to persist marks for specific files (e.g. by putting the :Mark commands into a local vimrc) or occasions (by defining a custom command or mapping with these commands), and are an alternative to :MarkSave/Load.
  • ENH: Add <Plug>MarkSearchUsedGroupNext and <Plug>MarkSearchUsedGroupPrev to search in a next / previous used group. Suggested by Louis Pan.
  • ENH: Add <Plug>MarkSearchCascadeStartWithStop, <Plug>MarkSearchCascadeNextWithStop, <Plug>MarkSearchCascadeStartNoStop, <Plug>MarkSearchCascadeNextNoStop to search in cascading mark groups, i.e. first all matches for group 1, then all for group 2, and so on.
  • CHG: Duplicate mark#GetNum() and mark#GetGroupNum(). Rename the former into mark#GetCount() and have it return the number of actually defined (i.e. non-empty) marks.
  • ENH: Allow to give names to mark groups via :MarkName and new :Mark /{pattern}/ as {name} command syntax. Names will be shown during searching, and persisted together with the marks. This makes it easier to handle several marks and enforce custom semantics for particular groups.
  • Properly abort on error by using :echoerr.
  • Add dependency to ingo-library (vimscript #4433).

You need to separately install ingo-library (vimscript #4433) version 1.020 (or higher)!

2.8.5 29-Oct-2014
  • ENH: Add alternative <Plug>MarkConfirmAllClear optional command that works like <Plug>MarkAllClear, but with confirmation. Thanks to Marcelo Montu for suggesting this!
2.8.4 19-Jun-2014
  • To avoid accepting an invalid regular expression (e.g. "\(blah") and then causing ugly errors on every mark update, check the patterns passed by the user for validity.
  • CHG: The :Mark command doesn't query for a mark when the passed mark group doesn't exist (interactivity in Ex commands is unexpected). Instead, it returns an error.
2.8.3 23-May-2014
  • The additional mapping described under :help mark-whitespace-indifferent got broken again by the refactoring of mark#DoMark() on 31-Jan-2013. Finally include this in the script as <Plug>MarkIWhiteSet and mark#GetVisualSelectionAsLiteralWhitespaceIndifferentPattern(). Thanks to Greg Klein for noticing and prodding me to include it.
2.8.2 16-Dec-2013
  • BUG: :Mark cannot highlight patterns starting with a number. Use -range=0 instead of -count. Thanks to Vladimir Marek for reporting this.
2.8.1 22-Nov-2013
  • Allow to override the adding to existing marks via :[N]Mark! {pattern}.
  • ENH: Implement command completion for :[N]Mark that offers existing mark patterns (from group [N] / all groups), both as one regular expression and individual alternatives. The leading \< can be omitted.
2.8.0 01-Jun-2013
  • Also allow a [count] for <Leader>r to select (or query for) a mark group, as with <Leader>m.
  • CHG: Also set the current mark to the used mark group when a mark was set via <Leader>r and :Mark so that it is easier to determine whether the entered pattern actually matches anywhere. Thanks to Xiaopan Zhang for notifying me about this problem.
  • Add <Plug>MarkSearchGroupNext / <Plug>MarkSearchGroupPrev to enable searching for particular mark groups. Thanks to Xiaopan Zhang for the suggestion.
  • Define default mappings for keys 1-9 on the numerical keypad to jump to a particular group (backwards with <C-kN>). Their definition is controlled by the new g:mwDirectGroupJumpMappingNum variable.
  • ENH: Allow to store an arbitrary number of marks via named slots that can optionally be passed to :MarkLoad / :MarkSave. If the slot is all-uppercase, the marks will also be persisted across Vim invocations.
2.7.2 15-Oct-2012
  • Issue an error message "No marks defined" instead of moving the cursor by one character when there are no marks (e.g. initially or after :MarkClear).
  • Enable custom integrations via new mark#GetNum() and mark#GetPattern() functions.
2.7.1 14-Sep-2012
  • Enable alternative * / # mappings that do not remember the last search type through new <Plug>MarkSearchOrCurNext, <Plug>MarkSearchOrCurPrev, <Plug>MarkSearchOrAnyNext, <Plug>MarkSearchOrAnyPrev mappings. Based on an inquiry from Kevin Huanpeng Du.
2.7.0 04-Jul-2012
  • ENH: Implement :MarkPalette command to switch mark highlighting on-the-fly during runtime.
  • Add "maximum" palette contributed by rockybalboa4.
2.6.5 24-Jun-2012
  • Don't define the default <Leader>m and <Leader>r mappings in select mode, just visual mode. Thanks to rockybalboa4 for pointing this out.
2.6.4 23-Apr-2012
  • Allow to override 'ignorecase' setting via g:mwIgnoreCase. Thanks to fanhe for the idea and sending a patch.
2.6.3 27-Mar-2012
  • ENH: Allow choosing of palette and limiting of default mark highlight groups via g:mwDefaultHighlightingPalette and g:mwDefaultHighlightingNum.
  • ENH: Offer an extended color palette in addition to the original 6-color one. Enable this via :let g:mwDefaultHighlightingPalette = "extended" in your vimrc.
2.6.2 26-Mar-2012
  • ENH: When a [count] exceeding the number of available mark groups is given, a summary of marks is given and the user is asked to select a mark group. This allows to interactively choose a color via 99<Leader>m. If you use the mark-whitespace-indifferent mappings,

PLEASE UPDATE THE vnoremap <Plug>MarkWhitespaceIndifferent DEFINITION

  • ENH: Include count of alternative patterns in :Marks list.
  • CHG: Use ">" for next mark and "/" for last search in :Marks.
2.6.1 23-Mar-2012
  • ENH: Add :Marks command that prints all mark highlight groups and their search patterns, plus information about the current search mark, next mark group, and whether marks are disabled.
  • ENH: Show which mark group a pattern was set / added / removed / cleared.
  • FIX: When the cursor is positioned on the current mark, [N]<Leader>n / <Plug>MarkClear with [N] appended the pattern for the current mark (again and again) instead of clearing it. Must not pass current mark pattern when [N] is given.
  • CHG: Show mark group number in same-mark search and rename search types from "any-mark", "same-mark", and "new-mark" to the shorter "mark-*", "mark-N", and "mark-N!", respectively.
2.6.0 22-Mar-2012
  • ENH: Allow [count] for <Leader>m and :Mark to add / subtract match to / from highlight group [count], and use [count]<Leader>n to clear only highlight group [count]. This was also requested by Philipp Marek.
  • FIX: :Mark and <Leader>n actually toggled marks back on when they were already off. Now, they stay off on multiple invocations. Use :call mark#Toggle() / <Plug>MarkToggle if you want toggling.
2.5.3 02-Mar-2012
  • BUG: Version check mistakenly excluded Vim 7.1 versions that do have the matchadd() function. Thanks to Philipp Marek for sending a patch.
2.5.2 09-Nov-2011
  • Fixed various problems with wrap-around warnings:
  • BUG: With a single match and 'wrapscan' set, a search error was issued.
  • FIX: Backwards search with single match leads to wrong error message instead.
  • FIX: Wrong logic for determining l:isWrapped lets wrap-around go undetected.
2.5.1 17-May-2011
  • FIX: == comparison in s:DoMark() leads to wrong regexp (\A vs. \a) being cleared when 'ignorecase' is set. Use case-sensitive comparison ==# instead.
  • Refine :MarkLoad messages
  • Add whitespace-indifferent visual mark configuration example. Thanks to Greg Klein for the suggestion.
2.5.0 07-May-2011
  • ENH: Add explicit mark persistence via :MarkLoad and :MarkSave commands and automatic persistence via the g:mwAutoLoadMarks and g:mwAutoSaveMarks configuration flags. (Request from Mun Johl, 16-Apr-2010)
  • Expose toggling of mark display (keeping the mark patterns) via new <Plug>MarkToggle mapping. Offer :MarkClear command as a replacement for the old argumentless :Mark command, which now just disables, but not clears all marks.
2.4.4 18-Apr-2011
  • BUG: Include trailing newline character in check for current mark, so that a mark that matches the entire line (e.g. created by V<Leader>m) can be cleared via <Leader>n. Thanks to ping for reporting this.
  • FIX: On overlapping marks, mark#CurrentMark() returned the lowest, not the highest visible mark. So on overlapping marks, the one that was not visible at the cursor position was removed; very confusing! Use reverse iteration order.
  • FIX: To avoid an arbitrary ordering of highlightings when the highlighting group names roll over, and to avoid order inconsistencies across different windows and tabs, we assign a different priority based on the highlighting group.
2.4.3 16-Apr-2011
  • Avoid losing the mark highlightings on :syn on or :colorscheme commands. Thanks to Zhou YiChao for alerting me to this issue and suggesting a fix.
  • Made the script more robust when somehow no highlightings have been defined or when the window-local reckoning of match IDs got lost. I had very occasionally encountered such script errors in the past.
  • Made global housekeeping variables script-local, only g:mwHistAdd is used for configuration.
2.4.2 14-Jan-2011 (unreleased)
  • FIX: Capturing the visual selection could still clobber the blockwise yank mode of the unnamed register.
2.4.1 13-Jan-2011
  • FIX: Using a named register for capturing the visual selection on {Visual}<Leader>m and {Visual}<Leader>r clobbered the unnamed register. Now using the unnamed register.
2.4.0 13-Jul-2010
  • ENH: The MarkSearch mappings (<Leader>[*#/?]) add the original cursor position to the jump list, like the built-in [/?*#nN] commands. This allows to use the regular jump commands for mark matches, like with regular search matches.
2.3.3 19-Feb-2010
  • BUG: Clearing of an accidental zero-width match (e.g. via :Mark \zs) results in endless loop. Thanks to Andy Wokula for the patch.
2.3.2 17-Nov-2009
  • BUG: Creation of literal pattern via '\V' in {Visual}<Leader>m mapping collided with individual escaping done in <Leader>m mapping so that an escaped '\*' would be interpreted as a multi item when both modes are used for marking. Thanks to Andy Wokula for the patch.
2.3.1 06-Jul-2009
  • Now working correctly when 'smartcase' is set. All mappings and the :Mark command use 'ignorecase', but not 'smartcase'.
2.3.0 04-Jul-2009
  • All jump commands now take an optional [count], so you can quickly skip over some marks, as with the built-in */# and n/N commands. For this, the entire core search algorithm has been rewritten. The script's logic has been simplified through the use of Vim 7 features like Lists.
  • Now also printing a Vim-alike search error message when 'nowrapscan' is set.
2.2.0 02-Jul-2009
  • Split off functions into autoload script.
  • Initialization of global variables and autocommands is now done lazily on the first use, not during loading of the plugin. This reduces Vim startup time and footprint as long as the functionality isn't yet used.
  • Split off documentation into separate help file. Now packaging as VimBall.
2.1.0 06-Jun-2009
  • Replaced highlighting via :syntax with matchadd() / matchdelete(). This requires Vim 7.2 / 7.1 with patches. This method is faster, there are no more clashes with syntax highlighting (:match always has preference), and the background highlighting does not disappear under 'cursorline'.
  • Using winrestcmd() to fix effects of :windo: By entering a window, its height is potentially increased from 0 to 1.
  • Handling multiple tabs by calling s:UpdateScope() on the TabEnter event.
2.0.0 01-Jun-2009
  • Now using Vim List for g:mwWord and thus requiring Vim 7. g:mwCycle is now zero-based, but the syntax groups "MarkWordx" are still one-based.
  • Factored :syntax operations out of s:DoMark() and s:UpdateMark() so that they can all be done in a single :windo.
  • Normal mode <Plug>MarkSet now has the same semantics as its visual mode cousin: If the cursor is on an existing mark, the mark is removed. Beforehand, one could only remove a visually selected mark via again selecting it. Now, one simply can invoke the mapping when on such a mark.
1.6.1 31-May-2009
  • Publication of improved version by Ingo Karkat.
  • Now prepending search type ("any-mark", "same-mark", "new-mark") for better identification.
  • Retired the algorithm in s:PrevWord in favor of simply using <cword>, which makes mark.vim work like the * command. At the end of a line, non-keyword characters may now be marked; the previous algorithm preferred any preceding word.
  • BF: If 'iskeyword' contains characters that have a special meaning in a regexp (e.g. [.*]), these are now escaped properly.
  • Highlighting can now actually be overridden in the vimrc (anywhere before sourcing this script) by using ':hi def'.
  • Added missing setter for re-inclusion guard.
1.5.0 01-Sep-2008
  • Bug fixes and enhancements by Ingo Karkat.
  • Added <Plug>MarkAllClear (without a default mapping), which clears all marks, even when the cursor is on a mark.
  • Added <Plug>... mappings for hard-coded \*, \#, \/, \?, * and #, to allow re-mapping and disabling. Beforehand, there were some <Plug>... mappings and hard-coded ones; now, everything can be customized.
  • BF: Using :autocmd without <bang> to avoid removing all autocmds for the BufWinEnter event. (Using a custom :augroup would be even better.)
  • BF: Explicitly defining s:current_mark_position; some execution paths left it undefined, causing errors.
  • ENH: Make the match according to the 'ignorecase' setting, like the star command.
  • ENH: The jumps to the next/prev occurrence now print 'search hit BOTTOM, continuing at TOP" and "Pattern not found:..." messages, like the * and n/N Vim search commands.
  • ENH: Jumps now open folds if the occurrence is inside a closed fold, just like n/N do.
1.1.8-g 25-Apr-2008
  • Last version published by Yuheng Xie on vim.org.
1.1.2 22-Mar-2005
  • Initial version published by Yuheng Xie on vim.org.

Copyright: (C) 2008-2023 Ingo Karkat - (C) 2005-2008 Yuheng Xie - The VIM LICENSE applies to this plugin.

Maintainer: Ingo Karkat <[email protected]>

vim-mark's People

Contributors

fedorenchik avatar idbrii avatar inkarkat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-mark's Issues

Unknown function: ingo#err#Clear

I'm getting this error when using mark.vim on marking a word (installed with vim-plug)

Error detected while processing function mark#MarkCurrentWord[13]..mark#DoMark:
line 1:
E117: Unknown function: ingo#err#Clear
mark-5/<nmap>

error at vim open

When I open vim, mark plugin seems to have issue to load its history.

Whatever the file I open (even starting vim withotu any file), I get the following error:

Error detected while processing function <SNR>52_AutoLoadMarks:
line    1:
E691: Can only compare List with List
Error detected while processing function <SNR>52_AutoLoadMarks:
line    1:
E15: Invalid expression: g:mwAutoLoadMarks && exists('g:MARK_MARKS') && g:MARK_MARKS !=# '[]'

I tried to wipe the .nvinfo file, I still the same error.

  • nvim version: NVIM v0.3.2-1041-g05d8a46ec
  • mark version: 7d885bd Documentation: Minor: Use :set ^= instead of += for 'viminfo'
  • ingo-library version: 13674a6 Add ingo#collections#SortOnOneAttribute(), ingo#collections#PrioritySort(), and ingo#collections#SortOnTwoAttributes()

":NMark pattern" produces "E16: Invalid range" when N exceeds number of lines in buffer

When I execute the :Mark command with a highlight group number and a patterns, as for example,

:3Mark /hello/

and there are fewer than 3 lines in the buffer, Vim displays the error message

E16: Invalid range

I am using Mark-3.1.0, ingo-library-1.041 and Vim 8.2.1081 on Ubuntu 18.04. The behavior is the same using Vim 8.2.1101 on Windows 10.

The bug appears to be due to the definition of the :Mark command in plugin/mark.vim. The :Mark command is defined with the -range option, so Vim assumes that the number preceding the command is a range. When a highlight group number is used in front of the :Mark command, Vim sees this as a line number and if the line number does not exist, Vim issues the error message.

This can be fixed by replacing the -range option with the -count option, since only the parameter is used in the command. I have tried this fix and it has it worked so far.

issue when using base16 theme

This might be potentially be an issue with base16 themes (https://github.com/chriskempson/base16-vim) or likely something in my setup/environment, but I wanted to run this by you just in case and ask for help in debugging.
The problem is when I use one of the base16-themes (set in my vimrc), then setting a mark does not do any highlighting. There are otherwise no errors/messages, and if I toggle the mark at this point, the status message indicates the mark is actually getting cleared. However visually the selected word is not marked with coloring at all, even though the mark is getting set and cleared.
This happens only when I use the base16 theme. No issues at all with any other theme.

However I noticed the following which may offer some clues, maybe. After loading with base16 theme, if I do a MarkPalette extended (or any other palette) then setting the marks works just fine. The marks that I had set previously also now get highlighted (colored).
The problem also clears up if I load another vim colorscheme, and then load the base16 theme back again.

It's as if something somewhere is not getting initialized correctly or is getting overwritten during startup. Does this ring any bell for you?

Again this problem happens only when using a base16 theme, every other color theme I've possibly used has never exhibited this issue.

I'm using the latest vim sources and latest source of both base16 and vim-mark sources.

Thank you.

Marks don't show on top of ALE errors

Hi

I like to use ALE to check my files. When there are errors, ALE colours them which is great. But if I have a highlight mark set on a word, and that word is inside an error marked as an error by ALE, the mark doesn't show up. Even if I set

hi ALEError gui=NONE

Is there any way to give marks a higher precedence so they show up on top of these errors?

Thanks

Ability to use n/N to perform `MarkSearchAnyNext`/`MarkSearchAnyPrev`

Motivation

I want to use vim's regular n and N keys to cycle forward/backward through any mark if there is any mark defined. Otherwise, I'd like n and N to perform their usual function.

Request and Purpose

If there are any marks defined, I'd like n and N to perform MarkSearchAnyNext and MarkSearchAnyPrev, respectively. If there are no marks, or all the marks are disabled, I'd like n and N to fall back to their usual function.

This should obviously be configurable as not all users will want this.

Alternatives

Alternatively, adding, removing or toggling marks could update vim's last search pattern. The downside of this solution is that you lose the ability to highlight each mark in a separate colour (at least until you do :nohl).

How to delete the slot saved by MarkSave

Frequent Issues

  • E117: Unknown function: ingo#...: Have you installed the ingo-library plugin (or via GitHub) as well, as documented in the dependencies section of the readme and plugin help?
  • Sudden problems after updating: Did you check out the default master branch? Unless you want to participate in feature development and alpha testing, I would recommend that you switch from master to the stable branch; this way, you'll only update to released versions that are (hopefully) better tested and documented.
  • Neovim: I don't explicitly consider nor test Neovim compatibility; my plugins are written for Vim. If a plugin can be made to work on Neovim with trivial changes, I wouldn't mind including them, but anything more involved should in my opinion be filed as a compatibility bug against Neovim (as its homepage proclaims: Fully compatible with Vim's editing model and the Vimscript language.)

Describe the bug

A clear and concise description of what the bug is.

How to Reproduce

Detailed steps to reproduce the behavior.

Expected Behavior

A clear and concise description of what you expected to happen.

Environment

  • Plugin version (e.g. stable version 1.10) / revision a1b2c3d4 from the master branch
  • Dependency versions (e.g. ingo-library plugin, or external tool versions)
  • Vim version (e.g. 8.1.1234) Or paste the result of vim --version.
  • OS: (e.g. Ubuntu 18.04, Windows 10 1809, macOS 10.14)
  • Install method: (e.g. manually via Vimball or ZIP file, GitHub clone as pack plugin, Plugin manager NAME)
  • Other plugins / additional context if you think this could be important

Conflict with Jedi

Hi,
Great plugin! But i just found out that key mapping has conflict with vim-jedi plugin. Would it be possible to have remapping options via "let" ?

Can't copy marked word?

Hi Ingo, thank you for maintaining this plugin. Looking at the docs I can't seem to find a solution for this. If I mark a word by double-clicking it, it is not 'selected' in Vim, and therefore I cannot CTRL-C (in Windows) to copy this word to the clipboard anymore. So basically, if I double-click a word, it gets highlighted (good), but then I have to manually drag my mouse over it to "select" it for copy (bad). Is there a workaround for this that I'm missing?

Thank you!

Error when marking with "<Leader>m"

Hello,

When marking with "m" on mark-3.0.0, I get the following error.

Error detected while processing function mark#MarkCurrentWord[13]..mark#DoMark:line    1:
E117: Unknown function: ingo#err#Clear
mark-1/\<config\>
Press ENTER or type command to continue

Marking still works though.

More details comes below.

  • With mark-2.8.5, downloaded from vim.org, there is no issue.
  • With mark-3.0.0, downloaded from Github, this issue happens.

If you have any problem to reproduce the issue, let me know.

Regards,

Sangho

Installation instructions incomplete

while the changelog later mentions it, the installation section just tells to git clone this repo, while you need that ingo library repo too. It should be eplicitly mentioned in the installation section that it is needed.

Sourcing .vimrc file breaks highlighting

When I manually source .vimrc file (i.e. to load new settings), it make all highlighting disappear.

How to Reproduce

I use VIM 9.0 and plugin is installed via Vundle.

  1. Open gvim
  2. open .vimrc: :e $MYVIMRS
  3. I highlight some words by using leader-m (everything works fine)
  4. Source .vimrc: :so %
  5. Highlighting disappears and leader-m has no visual effect anymore. I see echo'ed commands, i.e. mark-3 cleared, etc. No error messages are visible.

I have to quit vim and start it again to make it work.

Expected Behavior

Sourcing .vimrc file should have no impact on plugin functionality.

Environment

  • Plugin version: latest revision 8927403 from the master branch
  • Dependency versions (latest ingo-library revision cb7c672)
  • Vim version:
    VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Jan 19 2023 10:45:53)
    Included patches: 1-1221
  • OS: (Ubuntu 22.10)
  • Install method: (Plugin manager Vundle)

The ingo_library dependency is really bad

Just for a few trivial MSG and ERR that nobody cares, we have to install a library containing at least 100 files, and 99.9% of them are not used by 99.9% of people.
This is just bad practice.

Marking a full line instead of just the matching text

I often want to highilght the entire line that matches a particular piece of text. I updated my copy of vim-mark as shown below to allow \M or :MarkLine to perform that function.

diff --git i/autoload/mark.vim w/autoload/mark.vim
index 0fd2cbd..0b9c482 100644
--- i/autoload/mark.vim
+++ w/autoload/mark.vim
@@ -58,7 +58,7 @@ function! s:IsIgnoreCase( expr )
 endfunction
 " Mark the current word, like the built-in star command.
 " If the cursor is on an existing mark, remove it.
-function! mark#MarkCurrentWord( groupNum )
+function! mark#MarkCurrentWord( fullLine, groupNum )
 	let l:regexp = (a:groupNum == 0 ? mark#CurrentMark()[0] : '')
 	if empty(l:regexp)
 		let l:cword = expand('<cword>')
@@ -69,6 +69,9 @@ function! mark#MarkCurrentWord( groupNum )
 			if l:cword =~# '^\k\+$'
 				let l:regexp = '\<' . l:regexp . '\>'
 			endif
+			if a:fullLine
+				let l:regexp = '.*' . l:regexp . '.*'
+			endif
 		endif
 	endif
 	return (empty(l:regexp) ? 0 : mark#DoMark(a:groupNum, l:regexp)[0])
@@ -85,8 +88,12 @@ function! mark#GetVisualSelection()
 	let &clipboard = save_clipboard
 	return res
 endfunction
-function! mark#GetVisualSelectionAsLiteralPattern()
-	return s:EscapeText(mark#GetVisualSelection())
+function! mark#GetVisualSelectionAsLiteralPattern( fullLine )
+	let l:text = s:EscapeText(mark#GetVisualSelection())
+	if a:fullLine
+		let l:text = '.*' . l:text . '.*'
+	endif
+	return l:text
 endfunction
 function! mark#GetVisualSelectionAsRegexp()
 	return substitute(mark#GetVisualSelection(), '\n', '', 'g')
@@ -389,7 +396,6 @@ function! mark#DoMark( groupNum, ... )
 			return [0, 0]
 		endif
 	endif
-
 	let regexp = (a:0 ? a:1 : '')
 	if empty(regexp)
 		if l:groupNum == 0
@@ -492,7 +498,7 @@ function! mark#DoMarkAndSetCurrent( groupNum, ... )
 
 	return l:result
 endfunction
-function! mark#SetMark( groupNum, ... )
+function! mark#SetMark( fullLine, groupNum, ... )
 	" For the :Mark command, don't query when the passed mark group doesn't
 	" exist (interactivity in Ex commands is unexpected). Instead, return an
 	" error.
@@ -503,6 +509,9 @@ function! mark#SetMark( groupNum, ... )
 	if a:0
 		let [l:pattern, l:nameArgument] = ingo#cmdargs#pattern#ParseUnescapedWithLiteralWholeWord(a:1, '\(\s\+as\%(\s\+\(.\{-}\)\)\?\)\?\s*')
 		let l:pattern = ingo#regexp#magic#Normalize(l:pattern)  " We'd strictly only have to do this for /{pattern}/, not for whole word(s), but as the latter doesn't contain magicness atoms, it doesn't hurt, and with this we don't need to explicitly distinguish between the two cases.
+		if a:fullLine
+			let l:pattern = '.*' . l:pattern . '.*'
+		endif
 		if ! empty(l:nameArgument)
 			let l:name = substitute(l:nameArgument, '^\s\+as\s*', '', '')
 			return mark#DoMarkAndSetCurrent(a:groupNum, l:pattern, l:name)
diff --git i/plugin/mark.vim w/plugin/mark.vim
index 543c5c1..243cf02 100644
--- i/plugin/mark.vim
+++ w/plugin/mark.vim
@@ -123,8 +123,10 @@ highlight def link SearchSpecialSearchType MoreMsg
 
 "- mappings -------------------------------------------------------------------
 
-nnoremap <silent> <Plug>MarkSet               :<C-u>if ! mark#MarkCurrentWord(v:count)<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
-vnoremap <silent> <Plug>MarkSet               :<C-u>if ! mark#DoMark(v:count, mark#GetVisualSelectionAsLiteralPattern())[0]<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
+nnoremap <silent> <Plug>MarkSet               :<C-u>if ! mark#MarkCurrentWord(0,v:count)<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
+vnoremap <silent> <Plug>MarkSet               :<C-u>if ! mark#DoMark(v:count, mark#GetVisualSelectionAsLiteralPattern(0))[0]<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
+nnoremap <silent> <Plug>MarkSetLine           :<C-u>if ! mark#MarkCurrentWord(1,v:count)<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
+vnoremap <silent> <Plug>MarkSetLine           :<C-u>if ! mark#DoMark(v:count, mark#GetVisualSelectionAsLiteralPattern(1))[0]<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
 vnoremap <silent> <Plug>MarkIWhiteSet         :<C-u>if ! mark#DoMark(v:count, mark#GetVisualSelectionAsLiteralWhitespaceIndifferentPattern())[0]<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
 nnoremap <silent> <Plug>MarkRegex             :<C-u>if ! mark#MarkRegex(v:count, '')<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>echoerr ingo#err#Get()<Bar>endif<CR>
 vnoremap <silent> <Plug>MarkRegex             :<C-u>if ! mark#MarkRegex(v:count, mark#GetVisualSelectionAsRegexp())<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>echoerr ingo#err#Get()<Bar>endif<CR>
@@ -160,9 +162,15 @@ nnoremap <silent> <Plug>MarkSearchCascadePrevNoStop     :<C-u>if ! mark#cascade#
 if !hasmapto('<Plug>MarkSet', 'n')
 	nmap <unique> <Leader>m <Plug>MarkSet
 endif
+if !hasmapto('<Plug>MarkSetLine', 'n')
+	nmap <unique> <Leader>M <Plug>MarkSetLine
+endif
 if !hasmapto('<Plug>MarkSet', 'x')
 	xmap <unique> <Leader>m <Plug>MarkSet
 endif
+if !hasmapto('<Plug>MarkSetLine', 'x')
+	xmap <unique> <Leader>M <Plug>MarkSetLine
+endif
 " No default mapping for <Plug>MarkIWhiteSet.
 if !hasmapto('<Plug>MarkRegex', 'n')
 	nmap <unique> <Leader>r <Plug>MarkRegex
@@ -222,9 +230,11 @@ delfunction s:MakeDirectGroupMappings
 
 "- commands -------------------------------------------------------------------
 
-command! -bang -range=0 -nargs=? -complete=customlist,mark#Complete Mark if <bang>0 | silent call mark#DoMark(<count>, '') | endif | if ! mark#SetMark(<count>, <f-args>)[0] | echoerr ingo#err#Get() | endif
+command! -bang -range=0 -nargs=? -complete=customlist,mark#Complete Mark if <bang>0 | silent call mark#DoMark(<count>, '') | endif | if ! mark#SetMark(0,<count>, <f-args>)[0] | echoerr ingo#err#Get() | endif
+command! -bang -range=0 -nargs=? -complete=customlist,mark#Complete MarkLine if <bang>0 | silent call mark#DoMark(<count>, '') | endif | if ! mark#SetMark(1,<count>, <f-args>)[0] | echoerr ingo#err#Get() | endif
 command! -bar MarkClear call mark#ClearAll()
 command! -bar Marks call mark#List()
+command! -bar MarkToggle call mark#Toggle()
 
 command! -bar -nargs=? -complete=customlist,mark#MarksVariablesComplete MarkLoad if ! mark#LoadCommand(1, <f-args>) | echoerr ingo#err#Get() | endif
 command! -bar -nargs=? -complete=customlist,mark#MarksVariablesComplete MarkSave if ! mark#SaveCommand(<f-args>) | echoerr ingo#err#Get() | endif

mark word issue

hi, I encountered the below issue, Could you please help to have a look? Thanks.

Error detected while processing function mark#MarkCurrentWord[13]..mark#DoMark:

:ver
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 10 2018 21:31:58)
Included patches: 1-1453

Distro: Ubuntu 18.04 LTS

apply only to certain filetypes

Hi,
is there an option to apply vim-mark only to certain filetypes?
I am using it persistently with denite and vimfiler, but do not want to have it active by default e.g. for python.
Thanks

Global variable to prevent default mappings

Motivation

The mappings defined are many and tools such as which-key will be over-filled. Moreover, if one doesn't like your mappings, he has to disable them one by one...

Request and Purpose

A global variable that conditions the set of default mappings

Window with WinBar gets smaller every time add or delete mark

Describe the bug

Window with WinBar gets smaller every time add or delete mark.
This happens in other window, that is, window where to add mark, and window with WinBar should be 2 different windows. And their location is: window with text above, window with WinBar directly below window with text where add / delete mark happens.

If there's no WinBar, this bug does not happen.

How to Reproduce

  1. Open vim or gvim
  2. ^Ws to split
  3. Focus 2nd window
  4. nnoremenu WinBar.test1 1.10 :anything
  5. nnoremenu WinBar.test2 1.20 :anything
  6. Focus 1st window
  7. use <Leader>m to mark & unmark any text
  8. observe splitted window gets smaller everytime mark or unmark happens.

Expected Behavior

Windows sizes don't change.

Environment

  • Plugin version: revision 4494d26 from the master branch
  • Dependency versions (e.g. ingo-library plugin): revision 76bc5d1 from master branch
  • Vim version (e.g. 8.2.2489)
  • result of vim --version:
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Feb 10 2021 11:11:17)
Included patches: 1-2489
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               -farsi             +mouse_sgr         +tag_binary
+arabic            +file_in_path      -mouse_sysmouse    -tag_old_static
+autocmd           +find_in_path      +mouse_urxvt       -tag_any_white
+autochdir         +float             +mouse_xterm       -tcl
+autoservername    +folding           +multi_byte        +termguicolors
+balloon_eval      -footer            +multi_lang        +terminal
+balloon_eval_term +fork()            -mzscheme          +terminfo
+browse            -gettext           +netbeans_intg     +termresponse
++builtin_terms    -hangul_input      +num64             +textobjects
+byte_offset       +iconv             +packages          +textprop
+channel           +insert_expand     +path_extra        +timers
+cindent           +ipv6              -perl              +title
+clientserver      +job               +persistent_undo   +toolbar
+clipboard         +jumplist          +popupwin          +user_commands
+cmdline_compl     +keymap            +postscript        +vartabs
+cmdline_hist      +lambda            +printer           +vertsplit
+cmdline_info      +langmap           +profile           +virtualedit
+comments          +libcall           -python            +visual
+conceal           +linebreak         +python3/dyn       +visualextra
+cryptv            +lispindent        +quickfix          +viminfo
+cscope            +listcmds          +reltime           +vreplace
+cursorbind        +localmap          +rightleft         +wildignore
+cursorshape       +lua/dyn           -ruby              +wildmenu
+dialog_con_gui    +menu              +scrollbind        +windows
+diff              +mksession         +signs             +writebackup
+digraphs          +modify_fname      +smartindent       +X11
+dnd               +mouse             +sound             -xfontset
-ebcdic            +mouseshape        +spell             +xim
+emacs_tags        +mouse_dec         +startuptime       +xpm
+eval              +mouse_gpm         +statusline        +xsmp_interact
+ex_extra          -mouse_jsbterm     -sun_workshop      +xterm_clipboard
+extra_search      +mouse_netterm     +syntax            -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/home/leonid/.local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cloudproviders -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/at-spi-2.0 -pthread -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: gcc -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lelf -lcanberra -lacl -lattr -lgpm -ldl
  • OS: Manjaro KDE
  • Install method: GitHub clone as pack plugin
  • Sometimes makes vim crash (maybe when terminal window is opened)

Cannot search github.com for this plugin because it is forked

Describe the bug

Due to how github search algorithm works, it's impossible to search for this plugin by it's name, that is: vim-mark.

This happens because this repo is forked from other one.

How to Reproduce

Search vim-mark from github.com front page, observe there are no results for vim-mark, even many pages down.

But less popular & less maintained scripts, that are not forks, will be shown.

I think this is serious issue in popularity of this plugin.

Expected Behavior

Remove forked from vim-scripts/Mark from this repo (make it not a fork somehow (maybe contact github.com stuff or recreate repo (in the long term, it will be beneficial still))).

Environment

  • github.com

for a multi-line mark, * on cursor degrades to vim search

Describe the bug

When I specify a multi line regular expression for match, use <Leader>/ is fine for next occurence, but after the cursor is on highlight, * don't jump to next mark, instead it becomes vim normal * which simply search for the word under cursor

How to Reproduce
For example, using the following text

This is a test
for inkarkat vim-mark
I want to mark a pattern
in multiple lines
the cursor is on the search
but * becomes vim superstar for normal search
  1. :Mark /.*vim.*\n.*pattern/, this will mark line 2 and line 3
  2. Using <Leader>/ to jump to the first(only) Mark match
  3. With the cursor on line 2, use *, this time it searches for for under cursor instead for the next mark occurrence

Environment

  • revision ae3370b from the master branch
  • Vim version 8.2.960
  • OS: (Windows 10 1803)
  • Install method: (Plugin manager Vundle)

Declare dependencies

Motivation

Installation of the plugin could be simplified with plugin managers that support dependency declarations like VAM or VimFlavor

Request and Purpose

Thanks to an addon-info.json installation with Vim-Addon-Manager could be transparent regarding dependencies. Just add the following file at the root of the projet:

{
  "name" : "vim-mark",
  "version" : "dev",
  "author" : "Ingo Karkat",
  "maintainer" : "Ingo Karkat",
  "repository" : {"type": "git", "url": "[email protected]:inkarkat/vim-mark.git"},
  "dependencies" : {
      "ingo-library" : {"type" : "git", "url" : "[email protected]:inkarkat/vim-ingo-library.git"}
  },
  "description" : "highlighter plugin",
  "homepage" : "https://github.com/inkarkat/vim-mark"
}

In vim-flavor case, the VimFlavor file could contain

flavor 'inkarkat/vim-ingo-library', '>= 4.2.0'

(the version number could be changed to what makes sense, or removed)

Note

As vim-py automatically updates its database with the scripts registered on vim.org, VAM could just use the dependency expressed with the symbolic name associated to ingo-library (or its number. For instance, I used to use Mark%2666 to install and update your plugin with VAM).

Setting mark as part of vim modeline

Motivation

I sometimes make custom marks when writing text files - highlighting certain words to make the text more readable.
It would be neat to not lose this the next time I open the file.

Request and Purpose

Support setting marks through modelines. E.g. adding this to the top of a file:

# vim: mark1 /foo/

I could not find a way of doing this in the help file, and the string modeline is nowhere in the help file, so I don't think this is possible at the moment?

Alternatives

Saving the file as some custom file extension .foo, then :!echo "1Mark foo" > ~/.vim/ftplugin/foo.vim

This is a reasonable approach if you have many files with similar file extensions, but it creates a bunch of crap in your vim config folder if you have single files. It also forces you to use "wrong" file extensions.

<leader>n doesn't work

When I am trying to clear all marks using <leader>n I get the following message:

"Do not pass empty pattern to disable all marks"

Is there anything I can do to solve this?

Currently I've changed the row:

nmap <unique> <Leader>n <Plug>MarkClear

to

nmap <unique> <Leader>n :MarkClear<cr>

Jumping with `<k1> .. <k9>` or `<C-k1> .. <C-k9>` does not seem to work.

The README says that I can directly jump to the next or previous occurrence of a particular highlight group by using the numeric keypad. However, it doesn't seem to actually work for me.

I have created two highlight groups by doing 1\m and 2\m. I'm then supposed to press a digit on the numeric keypad (1 or 2 in my case) in normal mode, without any leader key, right? That does nothing for me, even though there are occurrences of the marks above and below my cursor's current line. I do know the difference between the numeric keypad versus the row of digits above the letters on the keyboard. I have also ensured that Num Lock is on.

If I look at the key mappings using :nmap, I see that the numeric keypad digits should be mapped correctly:

n  <C-k9>        <Plug>MarkSearchGroup9Prev
n  <Plug>MarkSearchGroup9Prev * :<C-U>if ! mark#SearchGroupMark(9, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k9>          <Plug>MarkSearchGroup9Next
n  <Plug>MarkSearchGroup9Next * :<C-U>if ! mark#SearchGroupMark(9, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k8>        <Plug>MarkSearchGroup8Prev
n  <Plug>MarkSearchGroup8Prev * :<C-U>if ! mark#SearchGroupMark(8, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k8>          <Plug>MarkSearchGroup8Next
n  <Plug>MarkSearchGroup8Next * :<C-U>if ! mark#SearchGroupMark(8, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k7>        <Plug>MarkSearchGroup7Prev
n  <Plug>MarkSearchGroup7Prev * :<C-U>if ! mark#SearchGroupMark(7, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k7>          <Plug>MarkSearchGroup7Next
n  <Plug>MarkSearchGroup7Next * :<C-U>if ! mark#SearchGroupMark(7, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k6>        <Plug>MarkSearchGroup6Prev
n  <Plug>MarkSearchGroup6Prev * :<C-U>if ! mark#SearchGroupMark(6, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k6>          <Plug>MarkSearchGroup6Next
n  <Plug>MarkSearchGroup6Next * :<C-U>if ! mark#SearchGroupMark(6, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k5>        <Plug>MarkSearchGroup5Prev
n  <Plug>MarkSearchGroup5Prev * :<C-U>if ! mark#SearchGroupMark(5, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k5>          <Plug>MarkSearchGroup5Next
n  <Plug>MarkSearchGroup5Next * :<C-U>if ! mark#SearchGroupMark(5, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k4>        <Plug>MarkSearchGroup4Prev
n  <Plug>MarkSearchGroup4Prev * :<C-U>if ! mark#SearchGroupMark(4, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k4>          <Plug>MarkSearchGroup4Next
n  <Plug>MarkSearchGroup4Next * :<C-U>if ! mark#SearchGroupMark(4, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k3>        <Plug>MarkSearchGroup3Prev
n  <Plug>MarkSearchGroup3Prev * :<C-U>if ! mark#SearchGroupMark(3, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k3>          <Plug>MarkSearchGroup3Next
n  <Plug>MarkSearchGroup3Next * :<C-U>if ! mark#SearchGroupMark(3, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k2>        <Plug>MarkSearchGroup2Prev
n  <Plug>MarkSearchGroup2Prev * :<C-U>if ! mark#SearchGroupMark(2, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k2>          <Plug>MarkSearchGroup2Next
n  <Plug>MarkSearchGroup2Next * :<C-U>if ! mark#SearchGroupMark(2, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k1>        <Plug>MarkSearchGroup1Prev
n  <Plug>MarkSearchGroup1Prev * :<C-U>if ! mark#SearchGroupMark(1, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k9>        <Plug>MarkSearchGroup9Prev
n  <Plug>MarkSearchGroup9Prev * :<C-U>if ! mark#SearchGroupMark(9, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k9>          <Plug>MarkSearchGroup9Next
n  <Plug>MarkSearchGroup9Next * :<C-U>if ! mark#SearchGroupMark(9, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k8>        <Plug>MarkSearchGroup8Prev
n  <Plug>MarkSearchGroup8Prev * :<C-U>if ! mark#SearchGroupMark(8, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k8>          <Plug>MarkSearchGroup8Next
n  <Plug>MarkSearchGroup8Next * :<C-U>if ! mark#SearchGroupMark(8, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k7>        <Plug>MarkSearchGroup7Prev
n  <Plug>MarkSearchGroup7Prev * :<C-U>if ! mark#SearchGroupMark(7, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k7>          <Plug>MarkSearchGroup7Next
n  <Plug>MarkSearchGroup7Next * :<C-U>if ! mark#SearchGroupMark(7, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k6>        <Plug>MarkSearchGroup6Prev
n  <Plug>MarkSearchGroup6Prev * :<C-U>if ! mark#SearchGroupMark(6, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k6>          <Plug>MarkSearchGroup6Next
n  <Plug>MarkSearchGroup6Next * :<C-U>if ! mark#SearchGroupMark(6, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k5>        <Plug>MarkSearchGroup5Prev
n  <Plug>MarkSearchGroup5Prev * :<C-U>if ! mark#SearchGroupMark(5, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k5>          <Plug>MarkSearchGroup5Next
n  <Plug>MarkSearchGroup5Next * :<C-U>if ! mark#SearchGroupMark(5, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k4>        <Plug>MarkSearchGroup4Prev
n  <Plug>MarkSearchGroup4Prev * :<C-U>if ! mark#SearchGroupMark(4, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k4>          <Plug>MarkSearchGroup4Next
n  <Plug>MarkSearchGroup4Next * :<C-U>if ! mark#SearchGroupMark(4, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k3>        <Plug>MarkSearchGroup3Prev
n  <Plug>MarkSearchGroup3Prev * :<C-U>if ! mark#SearchGroupMark(3, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k3>          <Plug>MarkSearchGroup3Next
n  <Plug>MarkSearchGroup3Next * :<C-U>if ! mark#SearchGroupMark(3, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k2>        <Plug>MarkSearchGroup2Prev
n  <Plug>MarkSearchGroup2Prev * :<C-U>if ! mark#SearchGroupMark(2, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <k2>          <Plug>MarkSearchGroup2Next
n  <Plug>MarkSearchGroup2Next * :<C-U>if ! mark#SearchGroupMark(2, v:count1, 0, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>
n  <C-k1>        <Plug>MarkSearchGroup1Prev
n  <Plug>MarkSearchGroup1Prev * :<C-U>if ! mark#SearchGroupMark(1, v:count1, 1, 1)|execute "normal! \<C-\>\<C-n>\<Esc>"|echoerr ingo#err#Get()|endif<CR>

OS: Ubuntu Desktop Bionic Beaver x86-64
Vim version:

$ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 10 2018 21:31:58)
Included patches: 1-1453
Modified by [email protected]
Compiled by [email protected]
Huge version without GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    -tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
-clientserver      +job               -perl              +vertsplit
-clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           -python            +vreplace
+conceal           +linebreak         +python3           +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       -lua               -ruby              -X11
+dialog_con        +menu              +scrollbind        -xfontset
+diff              +mksession         +signs             -xim
+digraphs          +modify_fname      +smartindent       -xpm
-dnd               +mouse             +startuptime       -xsmp
-ebcdic            -mouseshape        +statusline        -xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              +mouse_gpm         +syntax            
+ex_extra          -mouse_jsbterm     +tag_binary        
+extra_search      +mouse_netterm     +tag_old_static    
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-NQEcoP/vim-8.0.1453=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl     -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm      

I'm using vim in Ubuntu Bionic Beaver's Terminal app, in the GNOME graphical desktop environment.
What can I do to help debug?

add 'missing dependency' error

Motivation

I've just installed the plugin without reading the documentation to simply try it out, as I usually do for vim plugins, and it greeted me with a confusing error:

Error detected while processing function mark#SetMark[18]..mark#DoMarkAndSetCurrent[9]..mark#DoMark:                                                                                                                                          
line    1:                                                                                                                                                                                                                                    
E117: Unknown function: ingo#err#Clear                                                                                                                                                                                                        
Error detected while processing function mark#SetMark[18]..mark#DoMarkAndSetCurrent[9]..mark#DoMark[32]..<SNR>175_MarkEnable[10]..mark#UpdateScope:                                                                                           
line    1:                                                                                                                                                                                                                                    
E117: Unknown function: ingo#window#iterate#All

At first I assumed the plugin was unmaintained, buggy or something was wrong with my setup, but I wanted it bad enough that I kept trying and found issue #5 that explains the problem.

Request and Purpose

Add an error message that simply states the plugin requires an additional dependency and where to find it. Preferably when the user tries to run the :Mark command (non-invasive), but alternatively when loading the plugin.

It is not super common for plugins to require another plugin and the error message make users assume something is broken and might cause them to uninstall the plugin altogether. It seems as though adding as simple if would be enough, so it would be a simple change.

allow not clearing mark when it re-added

Motivation

In vim I use fugitive plugin :Git grep together with vim-mark plugin :Mark to search the word under coursor in code and show quick-fix window with matched lines with the searched word highlighted.

I use vim remap for this:

nnoremap gr :let @/=""<CR>:Mark <C-R><C-W><CR>:silent exec ":Ggrep! -w <C-R><C-W>"<CR>:copen<CR>:redr!<CR>

The result looks like this:

Screenshot from 2021-06-07 12-44-04

And I face the problem that when I want to search for already highlighted word (e.g.: search something second time while it's still highlighted), :Mark would just clear the mark on the word, but I don't want it to be cleared.

Request and Purpose

So I need a way (instead of just Toggle) to add a mark if it is not yet added and don't clear the mark if it's already there.

I've added a draft POC of what I mean. https://github.com/Snorch/vim-mark/tree/dont-clear-mark-if-exists But I'm not too good at vim plugin writing, and failed to find a proper place to integrate it, it looks like a crutch now. But with this I can grep same words multiple time with my command without losing highlight, and I can still clear the mark with <Leader>m when needed.

Probably I'm doing something wrong, or just don't see how to do it properly, please help.

error occur when hightlighting cursor word!

screen shot 2018-03-18 at 22 09 53



VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 18 2018 21:31:49)
macOS version
Included patches: 1-1614
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +comments          +file_in_path      +linebreak         +mouse_urxvt       +quickfix          +terminal          +windows
+arabic            +conceal           +find_in_path      +lispindent        +mouse_xterm       +reltime           +terminfo          +writebackup
+autocmd           +cryptv            +float             +listcmds          +multi_byte        +rightleft         +termresponse      -X11
-autoservername    +cscope            +folding           +localmap          +multi_lang        +ruby              +textobjects       -xfontset
-balloon_eval      +cursorbind        -footer            -lua               -mzscheme          +scrollbind        +timers            -xim
+balloon_eval_term +cursorshape       +fork()            +menu              +netbeans_intg     +signs             +title             -xpm
-browse            +dialog_con        -gettext           +mksession         +num64             +smartindent       -toolbar           -xsmp
++builtin_terms    +diff              -hangul_input      +modify_fname      +packages          +startuptime       +user_commands     -xterm_clipboard
+byte_offset       +digraphs          +iconv             +mouse             +path_extra        +statusline        +vertsplit         -xterm_save
+channel           -dnd               +insert_expand     -mouseshape        +perl              -sun_workshop      +virtualedit       
+cindent           -ebcdic            +job               +mouse_dec         +persistent_undo   +syntax            +visual            
-clientserver      +emacs_tags        +jumplist          -mouse_gpm         +postscript        +tag_binary        +visualextra       
+clipboard         +eval              +keymap            -mouse_jsbterm     +printer           +tag_old_static    +viminfo           
+cmdline_compl     +ex_extra          +lambda            +mouse_netterm     +profile           -tag_any_white     +vreplace          
+cmdline_hist      +extra_search      +langmap           +mouse_sgr         -python            -tcl               +wildignore        
+cmdline_info      +farsi             +libcall           -mouse_sysmouse    +python3           +termguicolors     +wildmenu          
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework AppKit   -mmacosx-version-min=10.13 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.26.1/lib/perl5/5.26.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin -lpython3.6m -framework CoreFoundation  -lruby.2.5.0 -lobjc    
set nocompatible
let &rtp=&rtp.','.$HOME.'/.vim/bundle/vim-mark'
colorscheme desert "default setting 
filetype plugin indent on
syntax on
:Mark

:windo add a jumplist

noautocmd windo call call('mark#UpdateMark', a:000)

will add a needless jumplist entry, it will be better add keepjumps

noautocmd keepjumps windo call call('mark#UpdateMark', a:000)

Corupted git repository & git fsck needed ?

Hi I think some commit are corupted
during git clone [email protected]:inkarkat/vim-mark.git
when in .gitconfig

[transfer]
    fsckobjects = true
[fetch]
    fsckobjects = true
[receive]
    fsckObjects = true

I got error

error: object 62aa8276d8f3dac379b70c673baead4e11dbc1ec: badTimezone: invalid author/committer line - bad time zone
fatal: Error in object
fatal: index-pack failed

Without those settings I am able to clone repository but git fsck is needed

#-> git fsck
Checking object directories: 100% (256/256), done.
error in commit 62aa8276d8f3dac379b70c673baead4e11dbc1ec: badTimezone: invalid author/committer line - bad time zone
error in commit 0dad50d4b4fbf4fa12911e133dde2989cb482ea9: badTimezone: invalid author/committer line - bad time zone
error in commit 5cc4fb24c1f138a385e9a900854d2c7adda04dfc: badTimezone: invalid author/committer line - bad time zone
error in commit fc87ef1374b417f68c5c513c5baa3adc01e07078: badTimezone: invalid author/committer line - bad time zone
error in commit 0ab4b7e435dfc19c005e52844248afaeb941c361: badTimezone: invalid author/committer line - bad time zone
error in commit 30664f3a8ff17a3bc813167d7f714a007340035e: badTimezone: invalid author/committer line - bad time zone
Checking objects: 100% (975/975), done

Tiny Suggestion: Make clearer that one needs to install dependency vim-ingo-library

Motivation

Thank you so much for this plug-in! I used to use an obscur editor on Windows called emeditor because it lets you multi-highlight words. Now that I switched to Linux, I was desperate to find something that does the same. Couldn't find an editor with this feature built-in. I suspected Vim community must have made some customization that allows this. I'm so glad I find your plug-in!

I'm relatively new to Vim, especially the plug-ins side. It was not totally obvious to me how to install the plug-in.

Request and Purpose

Just add a small mention in the README that plug-in vim-ingo-library must be installed as well, The plug-in is mentioned in the dependencies section but it might not be clear enough to some that one has to explicitly install it and exactly where to find it.

I realize this requirement only after I got errors when trying to mark a word. Then, I went through the README again carefully making sure I didn't miss anything. I did read the dependencies before but assumed that it was already included with the plug-in. Then, I checked my local cloned vim-mark repo (downloaded by vim-plug) to verify if there was anything ressembling that dependency. Nothing. That's when I started to suspect I had to explicitly install it.

Alternatives

A clear and concise description of any alternative solutions or features you've considered.

Update marks failed.

I've got error on refreshing marks:

Error detected while processing function mark#UpdateScope[7]..mark#UpdateMark:                                                                                                                               
line    2:                                                                                                                                                                                                   
E117: Unknown function: ingo#actions#EvaluateOrFunc                                                                                                                                                          
E15: Invalid expression: ingo#actions#EvaluateOrFunc(l:Predicate) 

Which is caused by ingo#actions#EvaluateOrFunc which doesn't exists.

EvaluateOrFunc is not defined

hi, i get an error like:

E117: Unknown function: ingo#actions#EvaluateOrFunc
E15: 无效的表达式: ingo#actions#EvaluateOrFunc(l:Predicate)
处理 function mark#MarkCurrentWord[13]..mark#DoMark 时发生错误:
第    1 行:
E117: Unknown function: ingo#err#Clear
处理 function mark#MarkCurrentWord[13]..mark#DoMark[89]..<SNR>139_SetMark[7]..<SNR>139_EnableAndMarkScope[4]..mark#UpdateScope[7]..mark#UpdateMark 时发生错误:
第    2 行:
E117: Unknown function: ingo#actions#EvaluateOrFunc
E15: 无效的表达式: ingo#actions#EvaluateOrFunc(l:Predicate)

无效的表达式 means undefined function...

Suppress "mapping already exists"

I have mappings that vim-mark attempts to redefine, so at each vim startup, I get:

Error detected while processing /home/a84089393/.vim/bundle/vim-mark/plugin/mark.vim:
line  163:
E227: mapping already exists for  n

How can I suppress the warnings? Thanks in advance and a separate thank you for this great plugin.

[Unrelated to the plugin] Help creating an anonymizer plugin

Hi there,

I was hoping we could discuss an unrelated idea for a plugin I want to create, but I'm unsure which method would be the fastest and if it would be possible to accomplish in vim without much lag.

I want to create a buffer anonymizer. Something similar to mzggg?G`z, except instead of doing a ROT13 on the text it would convert all characters to squares. Basically, I want to achieve something similar to:

image

The problem is, I want to keep the current highlighting group of every character in the buffer after I swap each character for a square. Do you have an idea how might I go about doing that?

EDIT: I found a better image

[tag 3.0.0] Error call ingo#err#Clear()

Hi I used tag 3.0.0 and I got error

Error detected while processing function mark#MarkCurrentWord[13]..mark#DoMark:
line    1:
E117: Unknown function: ingo#err#Clear

I have impression that functions there by accident.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.