sponsor Vim development Vim logo Vim Book Ad

wokmarks.vim : local marks usage more similar to other editors

 script karma  Rating 27/12, Downloaded by 2011  Comments, bugs, improvements  Vim wiki

created by
Andy Wokula
 
script type
utility
 
description
Lets you set and toggle a mark on a line without specifying which mark to use exactly.  wokmarks will choose an unused mark from a pool of allowed marks.  The script is quite verbose: you will get info which mark was set, removed or jumped to.


Usage: (default keys)

tm
set pool mark for current line (if no local mark exists)

tt
toggle pool mark for current line

tk
tj
jump to the [count]th local mark above/below the cursor position (like [' and ]' which are less verbose).
Without count, the search for marks wraps around the buffer boundaries.

tl
list local marks

tD
remove all pool marks from the buffer or pool marks in range

"t" actually is a built-in command; see below if you want to map other keys in the vimrc.
Local marks = pool marks + user marks.  User marks will not be set or removed by the script.

v0.3: The toggle hook will be executed whenever wokmarks adds or removes marks.  Purpose is to be able to update external marks highlighting etc.  Add a command to the hook:

     :autocmd User WokmarksChange   :MyMarksHighlightingUpdate

This must not be wrapped in an augroup -- this way you can define the autocmd before wokmarks is loaded.


Customization:

:let g:wokmarks_pool = "abcdfghijklmnopqrtuvwxyz"
(string)
Pool of allowed marks.  The marks s and e excluded here (user marks), they are commonly used for start and end positions.

:let g:wokmarks_do_maps = 1
(number)
Values:
0    don't map any keys
1    map the default keys
2    map Ctrl-F2 to toggle a mark, and  F2 / Shift-F2 to jump to the next or previous mark

The default keys are being mapped this way:
:map tk <Plug>PrevMarkWok
:map tj <Plug>NextMarkWok
:nmap tt <Plug>ToggleMarkWok
:nmap tm <Plug>SetMarkWok
:map tD <Plug>KillMarksWok
:nnoremap <silent> tl :marks abcdefghijklmnopqrstuvwxyz<CR>


Credits must go to vimscript #66

2010 Mar 28
 
install details
rename the file to wokmarks.vim
this is a global plugin, :h add-plugin
 

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
wokmarks_0.3.1.vim 0.3.1 2010-08-17 7.0 Andy Wokula - fix: the hook executed modelines (via :doautocmd, wtf?); reset 'modeline'
wokmarks_0.3.vim 0.3 2010-03-28 7.0 Andy Wokula - added toggle hook (:au User WokmarksChange) (Tom Link)
- added Wokmarks_GetLocalMarks()
wokmarks_0.2.vim 0.2 2009-11-01 7.0 Andy Wokula - tj tk set the ' mark, to allow jumping back with CTRL-O
- added Omap mode for <Plug>NextMarkWok, <Plug>PrevMarkWok
- let Wokmarks_GetMark() also accept ".", "$", etc.
- if g:wokmarks_do_maps == 2, then F2 maps are used (Tom Link)
- prev/next mark searches wrap around (Tom Link)
wokmarks_0.1.vim 0.1 2009-01-22 7.0 Andy Wokula Initial upload
ip used for rating: 18.116.118.198

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