Skip to main content
31 votes
Accepted

Why does dt$ not delete until the end of line?

Because t takes a character, so it looking for a literal $ character, not a motion like end of line
Eric Renouf's user avatar
7 votes
Accepted

text object for highlighted text

You can do: gnc gn will do a visual selection of the search result, then c is, as you know, change. Also, cgn works (change the next occurence of the search result).
padawin's user avatar
  • 1,333
6 votes
Accepted

Automatically jump to text object during `ci(`

The wellle/targets.vim plugin should do what you're looking for (and much more). This allows you to explicitly tell vim to go to the next parenthesis (with cin(, n for next parenthesis), or the last ...
DJMcMayhem's user avatar
  • 17.7k
6 votes

How to select/delete/yank the contents of only the current fold?

To delete the current fold, you simply have zd for instance Otherwise, you could also define an operator-pending mode mapping with for instance: :onoremap iz :<c-u>normal! [zV]z<cr> ...
Luc Hermitte's user avatar
  • 17.6k
6 votes
Accepted

How to select/delete/yank the contents of only the current fold?

There is no text object for folds in vim, but there is a plugin which provides them, az/iz: https://github.com/kana/vim-textobj-fold Here are vanilla alternatives: vi{/va{. This may or may not ...
Mass's user avatar
  • 14.2k
6 votes
Accepted

Remap standard motions

If you start with this normal mode mapping: nnoremap <buffer> $ f\|ge The visual-mode mapping is identical: vnoremap <buffer> $ f\|ge Then, for operator-pending mode (like after d, y, ...
Ingo Karkat's user avatar
  • 17.9k
5 votes

Why doesn't gJip turn a paragraph into a line?

The answer is simple: gJip doesn't work, because gJ is not an operator. See :h operator for which operators exist. The easy workaround is to use visual mode, and then join all the lines, e.g. use ...
Christian Brabandt's user avatar
5 votes

Why does dt$ not delete until the end of line?

t (and its variants T, f and F) take a single character afterwards to denote the target of motion within the line. So the effects of the two commands are: d$ - delete to end of current line dt$ - ...
mattp's user avatar
  • 51
5 votes

Is there a way to "move to the beginning of the next text object"?

For the general case, you can try creating new operators, gs and ge: function! GoStart(type) abort normal! `[ endfunction function! GoEnd(type) abort normal! `] endfunction nnoremap <silent&...
Rich's user avatar
  • 32.3k
5 votes
Accepted

Word motion and dots behaves differently in bash scripts

This comes down to the iskeyword setting. When I run :set iskeyword? in a bash file, I get this: iskeyword=@,48-57,_,192-255,. When I run the same command with a python file, I get this: iskeyword=@...
DJMcMayhem's user avatar
  • 17.7k
5 votes

How to join lines within a block with `J`?

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 ...
Matt's user avatar
  • 21k
5 votes
Accepted

delete from current position to end of paragraph when using hard wrap

You can use the } motion, which moves forward a paragraph, together with d, as in d}. This will delete from the cursor position until the next blank line (not including the blank line itself), which I ...
filbranden's user avatar
  • 29.1k
4 votes
Accepted

Why does replace not accept a motion?

Actually. There is no reason, apart from things being as they are, that would be against an r operator. The simple fact that viwra works means that riwa could work. The reason is simply a historical ...
VanLaser's user avatar
  • 9,820
4 votes
Accepted

How can I shift only inner contents of HTML element?

That's a great opportunity to leverage text objects (see :help text-objects). The following code extends the normal behavior of the it text object (see :help it and :help tag-blocks) to make it ...
Jair López's user avatar
  • 1,854
4 votes

How can I delimit sentences by carriage return?

If you tried reedes/vim-textobj-sentence, that (hopefully) means you have kana/vim-textobj-user installed. You can (mostly) trivially use this to define your own sentence. Treat this as a starting ...
brhfl's user avatar
  • 294
4 votes

Is there a way to "move to the beginning of the next text object"?

This doesn't answer your more general question about text objects, but you can achieve the behaviour in your specific indentation-based example with folds: setlocal foldmethod=indent setlocal ...
Rich's user avatar
  • 32.3k
4 votes
Accepted

"Visual around two Words"?

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 ...
Maxim Kim's user avatar
  • 13.7k
4 votes

Why doesn't Vim recognize a pair of <\> as a single unit?

I have noticed that regression, too, which seems to affect all text objects with single character boundaries: i< i" i' i{ etc. You should report it if it hasn't been reported already. EDIT ...
romainl's user avatar
  • 41.4k
3 votes

Is there a way to "move to the beginning of the next text object"?

Plugin vim-ninja-feet by tommcdo Currently, this plugin provides following square bracket mappings (do not overlook the square in the definition): {operator}[{text object} ...
Hotschke's user avatar
  • 4,800
3 votes

Is there a text object or motion for non-comment lines are not separated from comment lines by blank lines? E.g., in git commit messages

Define syntax match gitcommitBody for the custom text object syntax Install vim-textobj-user and vim-textobj-syntax. The default syntax file for gitcommit does not define gitcommitBody. Place ...
Hotschke's user avatar
  • 4,800
3 votes
Accepted

Abort an operating pending mapping

This works for me: :function! Foo() call feedkeys("\<esc>") return :endfunction This works since you can hit esc in operator pending mode (for example, c<esc>), and it will not ...
DJMcMayhem's user avatar
  • 17.7k
3 votes
Accepted

Is there a motion to select the comment block under the cursor?

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 ...
filbranden's user avatar
  • 29.1k
2 votes
Accepted

onoremap: defining a bounded region

Have you looked at Quick search, limited to a C++ function all the techniques presented in this discussion shall apply to your question. I'm not sure my solution is checking the cursor is within a ...
Luc Hermitte's user avatar
  • 17.6k
2 votes

Act on lines changed by previous command

As @romainl said, you can use the [ and ] marks for this purpose, e.g.: nnoremap gc `[v`] Pressing gc visually select the previous change. :'[,']s/var_name/varName/g Replace in the last modified ...
nobe4's user avatar
  • 16.2k
2 votes

Why does replace not accept a motion?

Not an answer, but a piece of code I used to "simulate" the functionality of an operator with r: function! ROperator() call inputsave() let l:replace_pattern = input('Replace > ') call ...
nobe4's user avatar
  • 16.2k
2 votes

Why does replace not accept a motion?

Replace is a specific type of situation, that I don't believe is equivalent to the others you listed that take motions. r can take an optional count, but the action is the same. 3ra replaces 3 ...
jecxjo's user avatar
  • 2,710
2 votes
Accepted

How can I delimit sentences by carriage return?

Update: Well, I made a plugin. Get it from ctholho/vim-textobj-sentence-line. The plugin supports is and as motions. I didn't test all possible conditions but it does the job reliably. It also remaps ...
ctholho's user avatar
  • 181
2 votes
Accepted

Changing content within the specified [count] number of braces for each line

The answer from @RubenWesterberg is a correct sequence of Normal mode commands to do what you want. But I read your request to not move the cursor a little more literally. Also, if you need to make ...
B Layer's user avatar
  • 20k
2 votes
Accepted

Inner-object possibilities

All of the text-objects are documented under :help text-objects. Excerpted from :help objects: |v_iquote| i" double quoted string without the quotes |v_i'| i' single quoted ...
D. Ben Knoble's user avatar
  • 26.8k

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