Skip to content

Conflict with popular plugin vim-surround #18

@sencer

Description

@sencer

Hi,

I liked your plugin, but it conflicts with vim-surround. Of course I can change the mappings for my self, but I think you also should think of something.

Actually a good idea might be overloading f, F, t, T keys so that if one presses two letters second one ~immediately after the first, these keys might work like your plugin. Otherwise they should act as vim default.

This is a simple script doing what I described, you might want to look at it:

function! Seek(dir, ...)

  let l:chr = getchar()
  if l:chr == 27 | return -1 | endif
  let l:string = a:dir . escape(nr2char(l:chr), '/*')
  sleep 200m | let l:chr = getchar(0)
  if l:chr != 0
    let l:string = l:string . escape(nr2char(l:chr), '/*')
  endif
  silent! exec "normal " . l:string . "\<CR>"
  if a:0 > 0
    exec "normal " . a:1
  endif
endfunction

nnoremap <silent> f :call Seek('/')<CR>
onoremap <silent> f :call Seek('/', 'l')<CR>
nnoremap <silent> F :call Seek('?')<CR>
onoremap <silent> F :call Seek('?')<CR>
nnoremap <silent> t :call Seek('/', 'h')<CR>
onoremap <silent> t :call Seek('/')<CR>
nnoremap <silent> T :call Seek('?', 'l')<CR>
onoremap <silent> T :call Seek('?', 'l')<CR>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions