New answers tagged

1

POSIX has this to say on the matter (emphasis added by me): https://pubs.opengroup.org/onlinepubs/9699919799/ Return to Previous (Context or Section) The [[, ]], (, ), {, and } commands are all affected by "section boundaries", but in some historical implementations not all of the commands recognize the same section boundaries. This is a bug, not ...


3

_fe should go to the first occurrence of e on that line. Can you give an example of where it doesn't? From :h _: _ <underscore> [count] - 1 lines downward, on the first non-blank character linewise. In other words, _ without a count moves to the first non-blank character of the current line, then fe goes to the first ...


0

I thought it might be helpful for others if I posted my final solution to my initial problem, although my directly asked question has been answered. With the help of Matt's obviously correct answer, I changed (copied from existing plugins) my final function to: function! SendWithMotion(type) if a:type == 'line' let lines = { 'start': line("'["...


1

Obviously, v means charwise selection, while you've got the linewise one (ip). So you must check the value of a:type and build the command in the right way with the help of :execute or plain :if etc.


4

I've had these mappings in my dotfiles for years and they are so useful that I forgot that it's not a built-in feature: " Quickly insert an empty new line without entering insert mode {{{ nnoremap <Leader>o o<Esc>0"_D nnoremap <Leader>O O<Esc>0"_D They are the equivalent of o and O but without entering insert mode. The ...


4

If installing a plugin is an option, Tpope's vim-unimpaired is a great pick which provides a mapping to insert empty lines: ]<space> to insert a line under the current line [<space> to insert a line above the current line Both accept a count, so 42]<space> will put 42 new lines under the current position.


1

So I tested your code a bit and I realized that the issue with your backward search comes from the flag z, I don't really have a convincing explanation because reading the doc I would have used it too. 'z' start searching at the cursor column instead of Zero I changed your pattern to a simple . and realized that <c-h> only matched the last character ...


2

As Matt says, use {operator}vj as per :help forced-motion. You can force line-wise, character-wise, and block-wise (think of it like "casting" the motion).


3

Usually you would have a separate mapping for an operator that would work on the current line and take a count to work on a set of lines. For example, you could have RJ{motion} to act on a motion or text object, and RJJ to act on the current line or on a set of lines if given a count. Having said that, you can have your mapping behave differently and act on ...


Top 50 recent answers are included