This is called "a motion". Even though linewise motions result in a line range. Normally, it's enough to do 5J and there's no need for "join" operator. However, if you really want it, you can make use of :h g@ and :h 'opfunc' A simplified example: " very basic "join" operator nnoremap <silent>J :set opfunc=OperJoin<CR>g@ function! OperJoin(type)...


If using plug-ins is acceptable to you, then the vim-commentary plug-in can help you. It defines a gc text object to select a comment, which you can use in operator pending mode. Use gqgc anywhere in the comment block to format the comment. Note that if you are using C or C++ you may need to tell Vim to use // comments instead of /**/ comments. You can ...


You can of course use v2aw, v3aw and so on as described in the :h text-objects where aw is a text object that accepts count. You can also compose viw and e. Like viwe for 2 words, viw2e for 3 words etc... So what is the difference with daw, caw and vaw? Why can't you 2vaw but 2daw works? d and c are operators (:h operator) -- they accept count + motion and ...


If you wanted to remap a(— onoremap a( :<C-u>normal! va(l<CR> This should make all uses of it include the space.


Plug-in wellle/targets.vim includes an operator mapping for this specific situation. The mapping is A( or Ab, which is analogous to a( but includes the whitespace following the pair. See the plug-in's documentation for the "Around Pair" operator.


You can control that with the 'selection' option. To disable the "past line" cursor behavior, use the following command: set selection=old Beware that using a non-default setting for this option is possibly likely to break behavior of some plug-ins, so it might not be a great idea to change it. There's also a motion that might be close to what you ...


Well, since J works in visual mode... va{J More generally v[motion or text object]J. Normally I would say this is a bit of an anti-pattern (prefer [operator][motion or text object]), but there is no join operator. Here, even v%J should work Alternately, use :join, which takes a range, and ranges can be quite powerful: .,/}/join


The commandline command you're looking for is 'j': :1,5j

Only top voted, non community-wiki answers of a minimum length are eligible