5

With the latest Vim version 8.2.2914, you can now simply paste without adding padding using the zp command.


3

Visual block mode (which you can enter with CTRL-V) is perfect for this kind of usage. You can copy and paste squares much like your router boxes and you can do so without shifting columns. Here is an example working with your initial diagram. Start by using a visual selection to copy the first router on the top left corner. First move to the upper left +, ...


3

Doing it quick and dirty: Select first column as V-BLOCK. Then press 40I<space><esc>, where "40" is number of spaces you want to add to center the picture. Or you can use :h v_> to shift by any number of shiftwidth() to the right.


2

I tend to like using :normal with a range for this kind of edit. Using :normal with a range is often similar to using a macro, but it can be more convenient in cases when: You want a single modification per line. (A macro can be more flexible in selecting what to modify.) You can express the whole command using only alpha-numeric characters (no need to ...


2

This is a good point to highlight a shortcoming of P (or the equivalent p) in Visual Block mode (more generally, in Visual mode.) It replaces the selected text, so it's not a great fit for this use case. While you can work around it, perhaps a more straightforward alternative would be to use Visual-block Insert and then use Ctrl+R to insert the contents of ...


2

Wow, actually it's easier than I thought! :h v_p reads The previously selected text is put in the unnamed register. therefore probably the best way to do what I want is Ctrl-V3jPp, or even Ctrl-V3jpp (because P and p seem to do the same in block-visual mode), where the latter p puts back what the former p deleted, right at the place it is needed.


2

Would it be possible to try it with a macro? Perform your yank command as you first describe (0y$). Move the cursor to the first period where you want to "put" the yanked line. Press q and then another key to store the macro (e.g. push q again) Press P and then j for the macro keys. Press q again to stop the macro recording. For the rest of the ...


2

I don't think there is a built-in way to achieve what you want to do, so I decided to try to implement it by myself. I got a working solution but this kind of text manipulation has a ton of corner cases and they are most probably not handled by my solution. Hopefully that will give you some inspiration to code your own (better) solution. Also there might ...


2

:help blockwise-operators: Visual-block Insert (...) Works only for adding text to a line, not for deletions. An alternative is to select the column to the left and use x or d, i.e., Ctrl-v3jd.


1

Here's a programmatic way of doing it. It's a bit complicated, but it only took me 5 minutes of trial and error to get right :) Here's the start: /path;text /path;text /path;text /subdir /longsubdir /longlongsubdir The key is to try to :join the matching lines with a :global command. We can do a touch up of the ordering and such later. A first attempt might ...


1

Not sure if you can avoid extra blanks... I would do it this way: select /subdir/ and other dirs with <C-v> + motion delete it go to /path's and paste befor ; select para and remove spaces with vip:norm! f diw There probably might be a better way with or without plugins, idk. PS, ofc the last command that deletes the spaces should depend on what you ...


1

There is no simple way to do it (considering all edge cases). You can try remapping solution: nnoremap <C-v> :setl nf+=alpha<CR><C-v> nnoremap v :setl nf+=alpha<CR>v nnoremap V :setl nf+=alpha<CR>V xnoremap <C-a> <C-a>:setl nf-=alpha<CR> xnoremap <C-x> <C-x>:setl nf-=alpha<CR> xnoremap <ESC&...


1

Would you try this? :%s/: \zs/\=@+ If you want space after the comma set your clipboard register before running the above command: :let @+='text from some register, '


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