Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage as operator / operating on a motion #144

Open
xeruf opened this issue May 14, 2020 · 1 comment
Open

Usage as operator / operating on a motion #144

xeruf opened this issue May 14, 2020 · 1 comment

Comments

@xeruf
Copy link

xeruf commented May 14, 2020

What I would like to do - maybe the plugin already supports this, but I at least couldn't find anything in the help - is mapping the commands as operators, similar to how it is done here: https://www.reddit.com/r/vim/comments/ebaoku/function_to_google_any_text_object/

This would solve #119 nicely - instead of changing anything, one could map the function OpenGithubProject to the operator gx and then simply type gxi' to open the project currently under the cursor. Of course this specific example applies to the derivative open-browser-github plugin, but it could be used in any way - you could search whole paragraphs or full WORDS.

@andrewferrier
Copy link

This is a great idea. For what it's worth, I already augment the behaviour of this plugin by adding this in a ~/.vim/after/plugin/open-browser.vim file:

function! s:open_browser(mode) abort
    call assert_true(a:mode ==# 'char')
    execute 'normal! `[v`]y'
    let l:new_value = getreg('"')
    call openbrowser#smart_search(l:new_value)
endfunction

nnoremap <silent> gX :<C-U>set opfunc=<SID>open_browser<CR>g@

This enables me to type things like gXi" to search for the text inside the double quotes, for example.

However, it would be great to see this behaviour built in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants