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

VSCode like multi select #1093

Closed
sandangel opened this issue Aug 17, 2019 · 0 comments
Closed

VSCode like multi select #1093

sandangel opened this issue Aug 17, 2019 · 0 comments

Comments

@sandangel
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I would like to have VSCode like multi select experience.
for example if I hit Ctrl-D, it will select the current word first, and the cursor position is still at the current word. then If I hit ctrl-d again, it will go to the next matched word and select it, the cursor position is at that next matched word

I tried with coc multi cursor and this is the code I have so far:

hi CocCursorRange guibg=#b16286 guifg=#ebdbb2
nmap <silent> <C-d> :call <SID>multi_select_word()<CR>

func! s:multi_select_word()
  if !get(b:, 'cursor_selected', 0)
    let b:cursor_selected = 1
    exec "norm \<Plug>(coc-cursors-word)"
  else
    exec "norm *\<Plug>(coc-cursors-word)"
  endif
endfunc

The only missing piece is a way to reset b:cursor_selected = 0 when I cancel the multi select. It can be an autocmd event, or override <ESC> mapping from coc (not ideal), or directly check the multi cursor is activated from coc like if coc#utils$is_multi_cursors_activated()

is there another way? Am I missing something?

chemzqm added a commit that referenced this issue Aug 17, 2019
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

1 participant