29

Because t takes a character, so it looking for a literal $ character, not a motion like end of line


5

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).


5

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, and so on), you need a different kind of mapping. :help omap-info tells us: To ignore the starting cursor position and select different text, you can have ...


5

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=@,48-57,_,192-255 If you have the filetype plugin set up, you could add this to your python file: set iskeyword+=. or this to your bash file (depending on ...


5

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$ - delete up-to-but-not-including a literal $ on the current line


4

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 point for experimentation - it seems to work well enough, but clobbers search etc; I'm sure it can be handled more cleanly: function! LinewiseSentenceI() let ...


4

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 select what you want, depending on whether your markers are in comments or not. [zV]z. Alternatively you can replace V with any operator. make your own: xnoremap ...


4

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 parenthesis (with cil(), but it also overrides the default so that you jump to the next or last if you don't specify. From the README: This overrides Vim's ...


3

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 following line syn match gitcommitBody "\%>2l[^#].*" contains=@Spell into the file ~/.vim/after/ftplugin/gitcommit.vim. This defines for all lines except the ...


3

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> Which will permit stuff like diz, ciz, yiz, =iz and so on. BTW, the related visual mode mapping would be: :xnoremap iz [zo]z


3

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 one, but there is nothing against an alternative implementation. It can help 'filling' some area defined by a motion/text-object with a single character. I ...


3

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 complete the operator.


2

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 function definition. To check for improper uses, you have to define a function. There, first record the current line, and then check the first and last line you ...


2

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 lines every var_name with varName If you want to use it in your function you can get informations about the last changed lines like so: let firstline = line("'[...


2

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 inputrestore() if len(l:replace_pattern) != 3 throw "Bad pattern size (expected 3)" endif let l:motion = strpart(replace_pattern, 0, 2) let l:char = ...


2

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 characters with the letter "a". In its current state, adding a motion would only allow for the repetition of the replace action. You could "replace word with the ...


2

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 consider multi-line HTML tags content as described in your post. In that way, you could also type in vit>, >it, dit, cit, yit and so on, with the extended ...


2

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 substitutions like this frequently you probably want something a bit less manual. You can use standard substitution in a mapping like this: :nnoremap <expr&...


2

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 the ) and ( motion to behave in the same way. Thanks to brhfl whose answer provided the building blocks for this. Based on the answer of brhfl I cobbled ...


2

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 vipgJ, because in visual mode gJ will join all those selected lines (see :h v_gJ). If you want to know the reason, why gJ and also J has not been implemented as an ...


1

It's in the docs, but you need to jump around a bit. :h i) says it's like [(, which in turn is like %, which is affected by 'cpoptions': When the '%' character is not present in 'cpoptions' |cpo-%|, parens and braces inside double quotes are ignored, unless the number of parens/braces in a line is uneven and this line and the previous one does not ...


1

i} *v_i}* *i}* *i{* i{ *v_iB* *v_i{* *iB* iB "inner Block", select [count] Blocks, from "[count] [{" to the matching '}', excluding the '{' and '}' (see |[{|). When used in Visual mode it is made characterwise. You can use getregtype() to check register type. Vi{ ...


1

Execute the following in normal mode on the first line: 2f{ci{REPLACEMENT_TEXT<ESC>0 This will find the target brace, change the content to REPLACEMENT_TEXT and then return the cursor back to the beginning of the line. For the second line: 4f{ci{REPLACEMENT_TEXT<ESC>0 Note that the exact number of braces to search for depend on if the first ...


1

So you just want to substitute something for } that moves down to the first non-empty line, i.e. the next paragraph? If I'm reading that right then... It's just an extra character to do this, ), but if }) is more than you want to type: :nnoremap } }) If you don't always want the new/modified movement you can add an alternate with the default movement: :...


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