vim-bookmarks
vim-bookmarks copied to clipboard
Multi-Line Bookmarks and Annotations for Visual Aids
It would be helpful if it was possible to bookmark multiple lines using Visual Mode.
Use Case
One use case would be to highlight or annotate multiple lines in a single go to provide visual aid when coming back to something. I use this plugin as a visual aid for keeping track of certain things quite often, and I've found that it's an exceptional use-case for this plugin.
Internally
Internally to the plugin itself, the bookmark could very well be recorded for the first line in the highlight with a number indicating how many additional lines to highlight.
Example
It's something I naturally attempted to do when I grabbed the plugin, and I think it would be an awesome addition to the plugin. The ability do to so using Ctrl+V or Shift+V would be superb and a natural way to highlight multiple lines.
Screenshots to demonstrate this use-case are below:
Currently, you can only mark a single line

Hopefully, we'd have the ability to bookmark a set of lines
Most likely, the g:bookmark_sign would only show up on the first line as the one that is actually bookmarked.

Here's a bit of a working, albeit verbose, example of what it might function like. Unfortunately, this simply adds a bookmark for every single line, instead of just adding one bookmark that highlights multiple lines. But it's a good demonstration, nonetheless:
expand .vimscript
highlight BookmarkSign ctermbg=NONE ctermfg=NONE
highlight BookmarkLine ctermbg=NONE guibg=#1a1a2a
let g:bookmark_sign = '>'
let g:bookmark_highlight_lines = 1
function! g:BookmarkMultiline() range
let file = expand("%:p")
if file ==# ""
return
endif
let first_line = line("'<")
if bm#has_bookmark_at_line(file, first_line)
if g:bookmark_show_toggle_warning ==# 1 && bm#is_bookmark_has_annotation_by_line(file, first_line)
let delete = confirm("Delete All Annotated bookmarks?", "&Yes\n&No", 2)
if (delete !=# 1)
echo "Ignore!"
return
endif
endif
for l:line_nr in range(line("'<"), line("'>"))
if bm#has_bookmark_at_line(file, l:line_nr) != 1
continue
endif
let bookmark = bm#get_bookmark_by_line(file, l:line_nr)
call bm_sign#del(file, bookmark['sign_idx'])
call bm#del_bookmark_at_line(file, l:line_nr)
endfor
echo "Bookmarks removed"
else
for l:line_nr in range(line("'<"), line("'>"))
if bm#has_bookmark_at_line(file, l:line_nr)
continue
endif
let sign_idx = bm_sign#add(file, l:line_nr, 0)
call bm#add_bookmark(file, sign_idx, l:line_nr, getline(l:line_nr), 0)
endfor
echo "Bookmarks added"
endif
endfunction
command! -range BookmarkMultiline <line1>,<line2>call g:BookmarkMultiline()
xnoremap mm :BookmarkMultiline<CR>
