Last active
August 29, 2015 14:04
-
-
Save rhysd/ff957a7411a1b743394d to your computer and use it in GitHub Desktop.
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
" このファイルを :so % なりで読み込んでから f{char} してみてください | |
function! s:inu_f() | |
let line = getline('.') | |
let col = col('.')-1 | |
let target_chars = [] | |
let lnum = line('.') | |
for end_col in reverse(range(col+1, len(line)-1)) | |
let searching_area = line[col : end_col-1] | |
let ch = line[end_col] | |
if stridx(searching_area, ch) == -1 | |
call matchaddpos('INUFLabel', [[lnum, end_col+1]], 999) | |
call add(target_chars, ch) | |
endif | |
endfor | |
redraw! | |
let cn = getchar() | |
let c = type(cn) == type(1) ? nr2char(cn) : cn | |
if index(target_chars, c) != -1 | |
call search('\C' . c, '', lnum) | |
endif | |
for h in filter(getmatches(), 'v:val.group ==# "INUFLabel"') | |
call matchdelete(h.id) | |
endfor | |
endfunction | |
augroup plugin-inu-f-highlight | |
autocmd! | |
autocmd ColorScheme * highlight default INUFLabel ctermfg=red ctermbg=NONE cterm=bold guifg=red guibg=NONE gui=bold | |
augroup END | |
highlight default INUFLabel ctermfg=red ctermbg=NONE cterm=bold guifg=red guibg=NONE gui=bold | |
nnoremap <silent>f :<C-u>call <SID>inu_f()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment