Skip to content

Instantly share code, notes, and snippets.

@saihoooooooo
Created October 25, 2013 02:37
Show Gist options
  • Select an option

  • Save saihoooooooo/7148671 to your computer and use it in GitHub Desktop.

Select an option

Save saihoooooooo/7148671 to your computer and use it in GitHub Desktop.
vim-operator-searchの残骸
map <SPACE>/ <Plug>(operator-search-forward)
map <SPACE>? <Plug>(operator-search-backward)
call operator#user#define('search-forward', 'OperatorSearch2', 'call OperatorSearchForward()')
call operator#user#define('search-backward', 'OperatorSearch2', 'call OperatorSearchBackward()')
let s:command_type = ''
function! OperatorSearchForward()
let s:command_type = '/'
endfunction
function! OperatorSearchBackward()
let s:command_type = '?'
endfunction
function! OperatorSearch2(motion_wise)
" v or V or <C-v>
let v = operator#user#visual_command_from_wise_name(a:motion_wise)
let save = @"
" textobjで選択した文字列を検索パターン用レジスタに格納
execute 'normal! `[' . v . '`]y'
let @/ = '\V' . substitute(escape(@", '\/'), '\n', '\\n', 'g')
let @" = save
" 強調表示
if &hlsearch
call feedkeys(":set hlsearch\<CR>", 'n')
endif
execute 'normal!' s:command_type "\<CR>"
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment