Created
October 25, 2013 02:37
-
-
Save saihoooooooo/7148671 to your computer and use it in GitHub Desktop.
vim-operator-searchの残骸
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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