sponsor Vim development Vim logo Vim Book Ad

mark_tools : Toggle and navigate marks

 script karma  Rating 12/3, Downloaded by 1256  Comments, bugs, improvements  Vim wiki

created by
Sergey Khorev
 
script type
utility
 
description
The plugin is another try on Vim marks. Often I end up using two separate mark groups for navigation (a-f and t-z) so I created a plugin to simplify this. Version 1.1 adds the ability to display marks in quickfix and location list windows.

Provided mappings:
<Plug>ToggleMarkAZ - mark/unmark current position, if there are multiple marks on the line, remove the first
<Plug>ToggleMarkZA - mark/unmark current position, if there are multiple marks on the line, remove the last
<Plug>ForceMarkAZ - add an unused mark starting from a, even if the position is marked
<Plug>ForceMarkZA - add an unused mark starting from z, even if the position is marked
<Plug>NextMarkPos - go to next mark
<Plug>PrevMarkPos - go to prev mark
<Plug>NextMarkLexi - go to previous mark in lexicographical order
<Plug>PrevMarkLexi - go to next mark in lexicographical order
<Plug>MarksLoc    - open location list window with local mark positions
<Plug>MarksQF     - open quickfix window with marks

Recommended mapping to put into your .vimrc:
nmap <Leader>a <Plug>ToggleMarkAZ
nmap <Leader>z <Plug>ToggleMarkZA
nmap <Leader>A <Plug>ForceMarkAZ
nmap <Leader>Z <Plug>ForceMarkZA
nmap <Leader>m <Plug>NextMarkPos
nmap <Leader>M <Plug>PrevMarkPos
nmap <Leader>l <Plug>NextMarkLexi
nmap <Leader>L <Plug>PrevMarkLexi
nmap <Leader>w <Plug>MarksLoc
nmap <Leader>W <Plug>MarksQF

So
\a and \z will toggle a mark at current line
\A and \Z force another mark
\m and \M go to next/prev mark
\l and \L go to next/prev mark alphabetically
\w and \W populate location list/quickfix window with marks

Also I suggest to install a plugin to visualise marks e.g. quickfixsigns (vimscript#2584)

Customisation:
toggle_marks_wrap_search variable controls whether search wraps around or not (order of precedence: w:toggle_marks_wrap_search, b:toggle_marks_wrap_search, g:toggle_marks_wrap_search)
Possible values:
-1 - use 'wrapscan' option value
0 - do not wrap
1 - always wrap (default)

Variables below define which marks should be displayed in loclist and quickfix windows respectively
let g:lmarks_names = 'abcdefghijklmnopqrstuvwxyz''.'
let g:gmarks_names = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'

I use the plugin on daily basis. If you found any problems or want to suggest a feature, drop me an email.
 
install details
Put into $VIMRUNTIME/plugin or source the plugin directly with ":so mark_tools.vim"

Also available on https://bitbucket.org/khorser/vim-mark-tools and https://github.com/khorser/vim-mark-tools
 

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

Click on the package to download.

package script version date Vim version user release notes
mark_tools.vim 1.1 2010-02-01 7.0 Sergey Khorev Renamed to mark_tools, added functionality to display marks in quickfix/loclist windows
toggle_local_marks.vim 1.0 2010-01-16 7.0 Sergey Khorev Initial upload
ip used for rating: 44.212.39.149

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