1
Fork 0

Removed last pattern seen

master
Joshua Potter 2017-05-17 00:01:25 -07:00
parent b6e562e89d
commit e8708d3a96
2 changed files with 7 additions and 15 deletions

View File

@ -7,13 +7,6 @@
" SCRIPT VARIABLES: " SCRIPT VARIABLES:
" ====================================================================== " ======================================================================
" s:last_pattern_seen :: String {{{2
" ----------------------------------------------------------------------
" The pattern last appended to a registry list.
let s:last_pattern_seen = @/
" s:active_register :: String {{{2 " s:active_register :: String {{{2
" ---------------------------------------------------------------------- " ----------------------------------------------------------------------
" The register currently active. This defaults to the unnamed register. " The register currently active. This defaults to the unnamed register.
@ -108,13 +101,13 @@ function! highlight#clear_all_registers()
endfunction endfunction
" FUNCTION: CountLastSeen() {{{1 " FUNCTION: CountPattern() {{{1
" ====================================================================== " ======================================================================
function! highlight#count_last_pattern_seen() function! highlight#count_pattern(pattern)
if len(@/) > 0 if len(@/) > 0
let pos = getpos('.') let pos = getpos('.')
exe ' %s/' . s:last_pattern_seen . '//gne' exe ' %s/' . a:pattern . '//gne'
call setpos('.', pos) call setpos('.', pos)
endif endif
endfunction endfunction
@ -144,7 +137,6 @@ endfunction
" ====================================================================== " ======================================================================
function! highlight#append_to_search(reg, pattern) function! highlight#append_to_search(reg, pattern)
let s:last_pattern_seen = a:pattern
if len(a:pattern) == 0 if len(a:pattern) == 0
return return
endif endif

View File

@ -37,13 +37,13 @@ endif
" Append Searches " Append Searches
noremap <Plug>HRegistry_AppendToSearch noremap <Plug>HRegistry_AppendToSearch
\ :call highlight#append_to_search(v:register, '\<'.expand('<cword>').'\>')<Bar> \ :call highlight#append_to_search(v:register, '\<'.expand('<cword>').'\>')<Bar>
\ call highlight#count_last_pattern_seen()<CR> \ call highlight#count_pattern('\<'.expand('<cword>').'\>')<CR>
noremap <Plug>HRegistry_GlobalAppendToSearch noremap <Plug>HRegistry_GlobalAppendToSearch
\ :call highlight#append_to_search(v:register, expand('<cword>'))<Bar> \ :call highlight#append_to_search(v:register, expand('<cword>'))<Bar>
\ call highlight#count_last_pattern_seen()<CR> \ call highlight#count_pattern(expand('<cword>'))<CR>
noremap <Plug>HRegistry_VisualAppendToSearch noremap <Plug>HRegistry_VisualAppendToSearch
\ :call highlight#append_to_search(v:register, highlight#get_visual_selection())<Bar> \ :call highlight#append_to_search(v:register, highlight#get_visual_selection())<Bar>
\ call highlight#count_last_pattern_seen()<CR> \ call highlight#count_pattern(highlight#get_visual_selection())<CR>
" Remove Searches " Remove Searches
noremap <Plug>HRegistry_RemoveFromSearch noremap <Plug>HRegistry_RemoveFromSearch
@ -57,7 +57,7 @@ noremap <Plug>HRegistry_ClearRegister
noremap <Plug>HRegistry_ActivateRegister noremap <Plug>HRegistry_ActivateRegister
\ :call highlight#activate_register(v:register)<CR> \ :call highlight#activate_register(v:register)<CR>
noremap <Plug>HRegistry_CountLastSeen noremap <Plug>HRegistry_CountLastSeen
\ :call highlight#count_last_pattern_seen()<CR> \ :call highlight#count_pattern('\<'.expand('<cword>').'\>')<CR>
" Normal Mappings " Normal Mappings
nmap <silent> & <Plug>HRegistry_AppendToSearch nmap <silent> & <Plug>HRegistry_AppendToSearch