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

Quotes support for VIM #341

Open
laktak opened this issue Mar 4, 2024 · 1 comment
Open

Quotes support for VIM #341

laktak opened this issue Mar 4, 2024 · 1 comment

Comments

@laktak
Copy link

laktak commented Mar 4, 2024

As quotes are not supported for VIM (#234) I use the following workaround:

" modified from https://github.com/airblade/vim-matchquote

let s:quotes = ['"', '''', '`']

function! s:matchquote()
  normal! m'

  " character_at_cursor
  let c = matchstr(getline('.'), '\%'.col('.').'c.')

  if index(s:quotes, c) >= 0

    let num = len(split(getline('.'), c, 1)) - 1
    if num % 2 == 1
      return
    endif

    " is quotation mark under cursor odd or even?
    let col = getpos('.')[2]
    let num = len(split(getline('.')[0:col-1], c, 1)) - 1

    let mvmt = num % 2 == 0 ? 'F' : 'f'
    execute 'normal!' mvmt.c
  else
    " fallback
    execute "normal \<plug>(matchup-%)"
  endif

endfunction

nnoremap <silent> <Plug>(MatchMetaN) :call <SID>matchquote()<CR>

And then map this for normal mode:

nmap % <Plug>(MatchMetaN)

Just in case you want to include this in some form.

@eyalk11
Copy link

eyalk11 commented May 25, 2024

Works great. Thanks! can't use nvim-treesitter due to conflict

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

No branches or pull requests

2 participants