New answers tagged

3

You can define your special version of "put" like this: command! -bar -bang -range -register Put call append(<line2> - <bang>0, getreg(<q-reg>, 1, 1)) Now 13Pu works without any jumping around.


8

If you're on Mac or Windows, there's no difference. On Linux they are different. If you only work in Vim, you really don't need either of them (I mean that you can live without them), as they are best used to interact with the outside world. Indeed, if you select something with your mouse (everywhere, not necessarily in the terminal; try by selecting some ...


5

The PRIMARY selection contains the currently selected text. You can paste it with the middle mouse button (or Shift+Insert in some terminals). The CLIPBOARD selection needs to be set explicitly with Control+C, and can be inserted with Control+V. This is essentially how Windows and macOS work. I always remember because the C from CLIPBOARD is for Control+C, ...


1

I'd play with g^a. Try 137i0^v137kg^a.


4

In general, for commands that involve {motion}, the cursor is placed at the beginning of the resulting text area. y8j starts at the current position and moves down, so the cursor does not move. y8k only includes the current line as the last yanked one, so it moves the cursor to the first yanked line, i.e. up. The same happens with motions inside a single ...


0

MacVim Cmd + x/c/v for cut/copy/paste If you use MacVim, the usual Cmd+x/c/v are defined in $VIMRUNTIME/macmap.vim which is sourced by default and hence are available without configuration: vnoremap <special> <D-x> "+x vnoremap <special> <D-c> "+y cnoremap <special> <D-c> <C-Y> nnoremap <special> <D-v&...


0

A slightly different variation using :h gn motion: let @a='' | g/prop="\zs.*\ze"/normal! "Aygn


4

You're confusing the passing of the register to :yank (Ex command) vs. y (normal mode). For the latter, instead of appending the register, it must come before the y command, and with the " prefix: "Ayi" (with register A, yank the inner " double quoted text) :let @a = '' | g/prop/normal! "Ayi" Note that as the yank is characterwise, all matches will be ...


0

Somebody had a similar problem: vim yank all matches of regex group into register. In your case regex will be prop="\zs.*\ze". \zs denotes where the match will start in the "substitution" (yanking to register), and \ze where to end.


1

The other answers addressed why this happens. One way around this that I prefer is just to use forward motions instead of backwards motions. Because w is an inclusive motion and b is an exclusive motion, in general you can do bdw instead of db In this particular case since you want to delete from the end of the line, you could use D to delete to the end ...


6

As per Matt's answer, b is an exclusive motion. Using visual mode is a possible way to work around this. Alternatively, you can also use v as an operator (instead of entering visual mode), like so: $dv3b See :help o_v, which explains it: v: When used after an operator, before the motion command: Force the operator to work characterwise, also when the ...


2

Matt's answer addresses the why, but requires the extra keypress of visual mode to solve your problem. (And there are suggestions that visual mode is less "vim-like", at least when alternatives are available.) For deleting the last 3 words, one sequence might be $3bD, no longer than your original, where you position first and delete last. A (much longer) ...


2

b is an :h exclusive motion, so it behaves this way: "the last character towards the end of the buffer is not included". Make sure you choose appropriate tools. Note that it's true for the normal mode. In the visual mode everything depends on :h 'selection' option value. So, if set selection=inclusive (default) then $v3bd does what you want.


Top 50 recent answers are included