1
0
mirror of https://github.com/gryf/.vim.git synced 2025-12-17 19:40:29 +01:00

Updated Mark plugin

This commit is contained in:
2011-05-23 20:43:28 +02:00
parent 8daa792c58
commit c12ebf43d0
4 changed files with 51 additions and 10 deletions

View File

@@ -7,7 +7,7 @@ ScriptID SourceID Filename
311 7645 grep.vim 311 7645 grep.vim
3304 15211 gundo.vim 3304 15211 gundo.vim
2727 11120 jsbeautify.vim 2727 11120 jsbeautify.vim
2666 15603 Mark 2666 15663 Mark
2262 8944 occur.vim 2262 8944 occur.vim
910 14691 pydoc.vim 910 14691 pydoc.vim
#2421 9423 pysmell.vim #2421 9423 pysmell.vim

View File

@@ -10,8 +10,19 @@
" Dependencies: " Dependencies:
" - SearchSpecial.vim autoload script (optional, for improved search messages). " - SearchSpecial.vim autoload script (optional, for improved search messages).
" "
" Version: 2.5.0 " Version: 2.5.1
" Changes: " 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 " 06-May-2011, Ingo Karkat
" - Also print status message on :MarkClear to be consistent with :MarkToggle. " - Also print status message on :MarkClear to be consistent with :MarkToggle.
" "
@@ -155,7 +166,7 @@ function! mark#MarkCurrentWord()
endif endif
endfunction endfunction
function! s:GetVisualSelection() function! mark#GetVisualSelection()
let save_clipboard = &clipboard let save_clipboard = &clipboard
set clipboard= " Avoid clobbering the selection and clipboard registers. set clipboard= " Avoid clobbering the selection and clipboard registers.
let save_reg = getreg('"') let save_reg = getreg('"')
@@ -167,10 +178,10 @@ function! s:GetVisualSelection()
return res return res
endfunction endfunction
function! mark#GetVisualSelectionAsLiteralPattern() function! mark#GetVisualSelectionAsLiteralPattern()
return s:EscapeText(s:GetVisualSelection()) return s:EscapeText(mark#GetVisualSelection())
endfunction endfunction
function! mark#GetVisualSelectionAsRegexp() function! mark#GetVisualSelectionAsRegexp()
return substitute(s:GetVisualSelection(), '\n', '', 'g') return substitute(mark#GetVisualSelection(), '\n', '', 'g')
endfunction endfunction
" Manually input a regular expression. " Manually input a regular expression.
@@ -348,8 +359,8 @@ function! mark#DoMark(...) " DoMark(regexp)
" clear the mark if it has been marked " clear the mark if it has been marked
let i = 0 let i = 0
while i < s:markNum while i < s:markNum
if regexp == s:pattern[i] if regexp ==# s:pattern[i]
if s:lastSearch == s:pattern[i] if s:lastSearch ==# s:pattern[i]
let s:lastSearch = '' let s:lastSearch = ''
endif endif
call s:SetPattern(i, '') call s:SetPattern(i, '')
@@ -394,7 +405,7 @@ function! mark#DoMark(...) " DoMark(regexp)
" choose a mark group by cycle " choose a mark group by cycle
let i = s:Cycle() let i = s:Cycle()
if s:lastSearch == s:pattern[i] if s:lastSearch ==# s:pattern[i]
let s:lastSearch = '' let s:lastSearch = ''
endif endif
call s:SetPattern(i, regexp) 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) . ')' execute 'let l:loadedMarkNum = mark#Load(' . g:MARK_MARKS . ', ' . (exists('g:MARK_ENABLED') ? g:MARK_ENABLED : 1) . ')'
if a:isShowMessages if a:isShowMessages
if l:loadedMarkNum == 0 if l:loadedMarkNum == 0
echomsg 'No persistent marks found' echomsg 'No persistent marks defined'
else 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
endif endif
catch /^Vim\%((\a\+)\)\=:E/ catch /^Vim\%((\a\+)\)\=:E/

View File

@@ -165,6 +165,9 @@ DEPENDENCIES *mark-dependencies*
============================================================================== ==============================================================================
CONFIGURATION *mark-configuration* 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 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 your vimrc file (or anywhere before this plugin is sourced), in the following
form (where N = 1..): > form (where N = 1..): >
@@ -199,6 +202,24 @@ command, but you can define some yourself: >
To remove the default overriding of * and #, use: > To remove the default overriding of * and #, use: >
nmap <Plug>IgnoreMarkSearchNext <Plug>MarkSearchNext nmap <Plug>IgnoreMarkSearchNext <Plug>MarkSearchNext
nmap <Plug>IgnoreMarkSearchPrev <Plug>MarkSearchPrev 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* LIMITATIONS *mark-limitations*
@@ -224,6 +245,13 @@ http://vim.wikia.com/wiki/Highlight_multiple_words:
============================================================================== ==============================================================================
HISTORY *mark-history* 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 2.5.0 07-May-2011
- ENH: Add explicit mark persistence via :MarkLoad and :MarkSave commands and - ENH: Add explicit mark persistence via :MarkLoad and :MarkSave commands and
automatic persistence via the g:mwAutoLoadMarks and g:mwAutoSaveMarks automatic persistence via the g:mwAutoLoadMarks and g:mwAutoSaveMarks

View File

@@ -442,6 +442,7 @@ loremipsum.txt loremipsum.txt /*loremipsum.txt*
mark-configuration mark.txt /*mark-configuration* mark-configuration mark.txt /*mark-configuration*
mark-dependencies mark.txt /*mark-dependencies* mark-dependencies mark.txt /*mark-dependencies*
mark-description mark.txt /*mark-description* mark-description mark.txt /*mark-description*
mark-highlight-colors mark.txt /*mark-highlight-colors*
mark-highlighting mark.txt /*mark-highlighting* mark-highlighting mark.txt /*mark-highlighting*
mark-history mark.txt /*mark-history* mark-history mark.txt /*mark-history*
mark-ideas mark.txt /*mark-ideas* mark-ideas mark.txt /*mark-ideas*
@@ -453,6 +454,7 @@ mark-persistence mark.txt /*mark-persistence*
mark-searching mark.txt /*mark-searching* mark-searching mark.txt /*mark-searching*
mark-todo mark.txt /*mark-todo* mark-todo mark.txt /*mark-todo*
mark-usage mark.txt /*mark-usage* mark-usage mark.txt /*mark-usage*
mark-whitespace-indifferent mark.txt /*mark-whitespace-indifferent*
mark.txt mark.txt /*mark.txt* mark.txt mark.txt /*mark.txt*
mark.vim mark.txt /*mark.vim* mark.vim mark.txt /*mark.vim*
multi_snip snipMate.txt /*multi_snip* multi_snip snipMate.txt /*multi_snip*