mirror of
https://github.com/gryf/.vim.git
synced 2025-12-17 11:30:29 +01:00
Updated Mark plugin
This commit is contained in:
@@ -7,7 +7,7 @@ ScriptID SourceID Filename
|
||||
311 7645 grep.vim
|
||||
3304 15211 gundo.vim
|
||||
2727 11120 jsbeautify.vim
|
||||
2666 15603 Mark
|
||||
2666 15663 Mark
|
||||
2262 8944 occur.vim
|
||||
910 14691 pydoc.vim
|
||||
#2421 9423 pysmell.vim
|
||||
|
||||
@@ -10,8 +10,19 @@
|
||||
" Dependencies:
|
||||
" - SearchSpecial.vim autoload script (optional, for improved search messages).
|
||||
"
|
||||
" Version: 2.5.0
|
||||
" Version: 2.5.1
|
||||
" Changes:
|
||||
"
|
||||
" 17-May-2011, Ingo Karkat
|
||||
" - Make s:GetVisualSelection() public to allow use in suggested
|
||||
" <Plug>MarkSpaceIndifferent vmap.
|
||||
" - FIX: == comparison in s:DoMark() leads to wrong regexp (\A vs. \a) being
|
||||
" cleared when 'ignorecase' is set. Use case-sensitive comparison ==# instead.
|
||||
"
|
||||
" 10-May-2011, Ingo Karkat
|
||||
" - Refine :MarkLoad messages: Differentiate between nonexistent and empty
|
||||
" g:MARK_MARKS; add note when marks are disabled.
|
||||
"
|
||||
" 06-May-2011, Ingo Karkat
|
||||
" - Also print status message on :MarkClear to be consistent with :MarkToggle.
|
||||
"
|
||||
@@ -155,7 +166,7 @@ function! mark#MarkCurrentWord()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:GetVisualSelection()
|
||||
function! mark#GetVisualSelection()
|
||||
let save_clipboard = &clipboard
|
||||
set clipboard= " Avoid clobbering the selection and clipboard registers.
|
||||
let save_reg = getreg('"')
|
||||
@@ -167,10 +178,10 @@ function! s:GetVisualSelection()
|
||||
return res
|
||||
endfunction
|
||||
function! mark#GetVisualSelectionAsLiteralPattern()
|
||||
return s:EscapeText(s:GetVisualSelection())
|
||||
return s:EscapeText(mark#GetVisualSelection())
|
||||
endfunction
|
||||
function! mark#GetVisualSelectionAsRegexp()
|
||||
return substitute(s:GetVisualSelection(), '\n', '', 'g')
|
||||
return substitute(mark#GetVisualSelection(), '\n', '', 'g')
|
||||
endfunction
|
||||
|
||||
" Manually input a regular expression.
|
||||
@@ -348,8 +359,8 @@ function! mark#DoMark(...) " DoMark(regexp)
|
||||
" clear the mark if it has been marked
|
||||
let i = 0
|
||||
while i < s:markNum
|
||||
if regexp == s:pattern[i]
|
||||
if s:lastSearch == s:pattern[i]
|
||||
if regexp ==# s:pattern[i]
|
||||
if s:lastSearch ==# s:pattern[i]
|
||||
let s:lastSearch = ''
|
||||
endif
|
||||
call s:SetPattern(i, '')
|
||||
@@ -394,7 +405,7 @@ function! mark#DoMark(...) " DoMark(regexp)
|
||||
|
||||
" choose a mark group by cycle
|
||||
let i = s:Cycle()
|
||||
if s:lastSearch == s:pattern[i]
|
||||
if s:lastSearch ==# s:pattern[i]
|
||||
let s:lastSearch = ''
|
||||
endif
|
||||
call s:SetPattern(i, regexp)
|
||||
@@ -675,9 +686,9 @@ function! mark#LoadCommand( isShowMessages )
|
||||
execute 'let l:loadedMarkNum = mark#Load(' . g:MARK_MARKS . ', ' . (exists('g:MARK_ENABLED') ? g:MARK_ENABLED : 1) . ')'
|
||||
if a:isShowMessages
|
||||
if l:loadedMarkNum == 0
|
||||
echomsg 'No persistent marks found'
|
||||
echomsg 'No persistent marks defined'
|
||||
else
|
||||
echomsg printf('Loaded %d mark%s', l:loadedMarkNum, (l:loadedMarkNum == 1 ? '' : 's'))
|
||||
echomsg printf('Loaded %d mark%s', l:loadedMarkNum, (l:loadedMarkNum == 1 ? '' : 's')) . (s:enabled ? '' : '; marks currently disabled')
|
||||
endif
|
||||
endif
|
||||
catch /^Vim\%((\a\+)\)\=:E/
|
||||
|
||||
28
doc/mark.txt
28
doc/mark.txt
@@ -165,6 +165,9 @@ DEPENDENCIES *mark-dependencies*
|
||||
==============================================================================
|
||||
CONFIGURATION *mark-configuration*
|
||||
|
||||
For a permanent configuration, put the following commands into your |vimrc|.
|
||||
|
||||
*mark-highlight-colors*
|
||||
You may define your own colors or more than the default 6 highlightings in
|
||||
your vimrc file (or anywhere before this plugin is sourced), in the following
|
||||
form (where N = 1..): >
|
||||
@@ -199,6 +202,24 @@ command, but you can define some yourself: >
|
||||
To remove the default overriding of * and #, use: >
|
||||
nmap <Plug>IgnoreMarkSearchNext <Plug>MarkSearchNext
|
||||
nmap <Plug>IgnoreMarkSearchPrev <Plug>MarkSearchPrev
|
||||
<
|
||||
*mark-whitespace-indifferent*
|
||||
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 following scriptlet: >
|
||||
function! s:GetVisualSelectionAsLiteralWhitespaceIndifferentPattern()
|
||||
return substitute(escape(mark#GetVisualSelection(), '\' . '^$.*[~'), '\_s\+', '\\_s\\+', 'g')
|
||||
endfunction
|
||||
vnoremap <silent> <Plug>MarkWhitespaceIndifferent <C-\><C-n>:call mark#DoMark(<SID>GetVisualSelectionAsLiteralWhitespaceIndifferentPattern())<CR>
|
||||
Using this, you can assign a new visual mode mapping <Leader>* >
|
||||
vmap <Leader>* <Plug>MarkWhitespaceIndifferent
|
||||
or override the default |v_<Leader>m| mapping, in case you always want this
|
||||
behavior: >
|
||||
vmap <Leader>m <Plug>MarkWhitespaceIndifferent
|
||||
<
|
||||
==============================================================================
|
||||
LIMITATIONS *mark-limitations*
|
||||
@@ -224,6 +245,13 @@ http://vim.wikia.com/wiki/Highlight_multiple_words:
|
||||
==============================================================================
|
||||
HISTORY *mark-history*
|
||||
|
||||
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
|
||||
|
||||
2
doc/tags
2
doc/tags
@@ -442,6 +442,7 @@ loremipsum.txt loremipsum.txt /*loremipsum.txt*
|
||||
mark-configuration mark.txt /*mark-configuration*
|
||||
mark-dependencies mark.txt /*mark-dependencies*
|
||||
mark-description mark.txt /*mark-description*
|
||||
mark-highlight-colors mark.txt /*mark-highlight-colors*
|
||||
mark-highlighting mark.txt /*mark-highlighting*
|
||||
mark-history mark.txt /*mark-history*
|
||||
mark-ideas mark.txt /*mark-ideas*
|
||||
@@ -453,6 +454,7 @@ mark-persistence mark.txt /*mark-persistence*
|
||||
mark-searching mark.txt /*mark-searching*
|
||||
mark-todo mark.txt /*mark-todo*
|
||||
mark-usage mark.txt /*mark-usage*
|
||||
mark-whitespace-indifferent mark.txt /*mark-whitespace-indifferent*
|
||||
mark.txt mark.txt /*mark.txt*
|
||||
mark.vim mark.txt /*mark.vim*
|
||||
multi_snip snipMate.txt /*multi_snip*
|
||||
|
||||
Reference in New Issue
Block a user