Comments (8)
I see that the word return
is also a target for a%
. Using gc1a%
works.
from vim-matchup.
However, given your example:
if condition
█call one()
call two()
endif
pressing di% will produce
if condition
endif
Should this work similar to vimscript functions for gc1i%
?
from vim-matchup.
Glad the first issue was resolved :) I've debated whether this should be configurable with an option.
[Edit] Ah I see what you mean now, gci%
comments too much?
" if condition
" █call one()
" call two()
endif
from vim-matchup.
I think the solution is
let g:matchup_text_obj_linewise_operators += [ 'g@' ]
can you confirm?
from vim-matchup.
No, I cannot confirm. Sorry for not adding an example for what I meant. But you already figured it out. Yes, I would expect that the if condition
would not be commented. Consider the vimscript function from above as a second example
function! s:test()
let l:str = "hello"
return l:str
endfunction
Place the cursor on the line with let ...
and press gc1i%
, I get
" function! s:test()
" let l:str = "hello"
" return l:str
endfunction
I would expect
function! s:test()
" let l:str = "hello"
" return l:str
endfunction
Using 1i%
for a visual selection shows that match-up works characterwise and just omits the matchword function
:
Well, this looks intended. I am not sure how to resolve this. Maybe enforcing linewise mode could be used and the i%
object does NOT include lines with match words when in linewise mode.
from vim-matchup.
Strange.. I cannot reproduce it with the following vimrc:
set nocompatible
" load match-up (and commentary)
for s:loc in ['bundle', 'plugged']
let &rtp = '~/.vim/'.s:loc.'/vim-matchup,' . &rtp
let &rtp .= ',~/.vim/'.s:loc.'/vim-matchup/after'
let &rtp = '~/.vim/'.s:loc.'/vim-commentary,' . &rtp
let &rtp .= ',~/.vim/'.s:loc.'/vim-commentary/after'
endfor
filetype plugin indent on
syntax enable
" match-up options go here
let g:matchup_text_obj_linewise_operators = ['d', 'y', 'g@', ':']
However, I think using :
for visual mode is unintuitive, so I added the following enhancement:
function! IsCommentaryOpFunc()
return &operatorfunc ==? matchstr(maparg('<Plug>Commentary', 'n'),
\ '\cset op\%(erator\)\?func=\zs.\{-\}\ze<cr>')
endfunction
let g:matchup_text_obj_linewise_operators = ['d', 'y',
\ 'g@,IsCommentaryOpFunc()', 'V']
Now you can specify exactly which visual modes and which operatorfunc
s (a bit complicated to determine) you want to act line-wise.
from vim-matchup.
Now, it works with
let g:matchup_text_obj_linewise_operators = ['d', 'y', 'g@', ':']
or your enhancement.
Can adding g@
and :
to linewise operators have side effects?
from vim-matchup.
Can adding g@ and : to linewise operators have side effects?
-
If you add
g@
, then any plugin which usesoperatorfunc
will be line-wise, which might be undesirable. That's why I added the syntaxg@,execute-string
, so you can check whatopfunc
is. If you don't care or don't use any other plugins, it won't matter. -
I don't think adding
:
(orv
,V
, and<c-v>
) will have any side-effects but I'm not completely sure. Note, this option only applies to thei%
text-object, so the effect should be limited.
from vim-matchup.
Related Issues (20)
- Feature: Option to set motion timeouts HOT 5
- [Feature Request]: Hybrid winbar/statusline option for offscreen matches HOT 11
- Treesitter integration broken on Javascript HOT 26
- Matchup error with treesitter in javascript files HOT 1
- Latest tree-sitter-c parser breaks vim-matchup HOT 1
- Add support for statuscolumn and foldcolumn in offscreen matches
- Error since last update → If treesitter matchup is enabled HOT 2
- Feature request: disable closing hint HOT 3
- offscreen doesn't display
- Wrong matching across strings HOT 2
- Crash when shell case is incomplete
- Matchup adding random characters on the beginning of the buffer. HOT 8
- clarification about lazy loading on keys HOT 6
- Incompatibility with nvim-cmp snippet completion HOT 8
- Matching string and char delimeters HOT 2
- how to activate ruby's `|` delimeter for block arguments HOT 4
- MatchParen(Cur) Highlight persists in virtual fold text
- invalid node type for language perl
- invalid node type for language bash HOT 5
- Svelte error was reported after treesitter's commit of svelte parsing HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-matchup.