4 ms·
I think you're referring to multiple cursors? Visual-Multi [0] is an amazing Vim plugin for this with advanced features like searching by regex, alignment by re
by maddyboo 5y ago
I think you're referring to multiple cursors? Visual-Multi [0] is an amazing Vim plugin for this with advanced features like searching by regex, alignment by regex, transposition, duplication, auto-numbering, and more.
You can ignore the advanced features at first, it's very intuitive: just `C-n` to find the next occurrence of the word or `\\a` to find all, and then whatever editing operation you want like `cfoobar<esc>`. Or to just get another cursor on the line below, `C-<down>`.
[0]: https://github.com/mg979/vim-visual-multi https://github.com/mg979/vim-visual-multi
- georgyo 5y agoThis is not multiple cursors. Ctrl+k is cut line, similar to yy Ctrl+u is paste, similar to p The difference is hitting Ctrl+k five times will put all those lines into a buffer. And Ctrl+u will paste those five lines. In vim, this is complicated. You could do 'y5' requiring to know/calculate the number of lines in advance. But more often then not you are going into visual mode, selecting everything, then y, then p. This is complicated series of distinct commands. It's a matter of preference, but I personally prefer Ctrl+k/u of nano over the vi/vim method.
- maddyboo 5y agoForgive me for misunderstanding the ambiguous comment, both C-k and C-u are associated with multiple cursors in VSCode [0] ;) I use the following mappings for emacs-ish editing in insert mode: " emacs-style editing & motion inoremap <C-a> <Home> inoremap <C-e> <End> inoremap <C-b> <Left> inoremap <C-f> <Right> inoremap <C-n> <Down> inoremap <M-b> <S-Left> inoremap <M-f> <S-Right> inoremap <M-d> <C-o>de inoremap <C-k> <C-o>D inoremap <C-p> <Up> inoremap <C-d> <Delete> " restore support for digraphs to M-k inoremap <M-k> <C-k> `C-k` doesn't append to a "kill ring", but you could probably accomplish that with something like inoremap <C-k> <C-o>"Kdd inoremap <silent> <C-u> <C-o>"Kp<C-o>:let @k=""<cr> Or if you want it in normal mode rather than insert mode: nnoremap <C-k> "Kdd nnoremap <silent> <C-u> "Kp:let @k=""<cr> Edit: This is the closest behavior I could get to how nano seems to do it: let @k="" let @l="" nnoremap <silent> <C-k> "ldd:let @k=@k.@l \| let @l=@k<cr> nnoremap <silent> <C-u> :if @l != "" \| let @k=@l \| end<cr>"KgP:let @l=@k<cr>:let @k=""<cr> The bigger point I'd like to make is that it's a bit silly to complain about vim's default behavior not being as you'd like it. This is the beauty of vim (and emacs): it's a solid foundation upon which to build your ideal workflow. Few people find vim's defaults to be entirely satisfactory, but with a bit of creativity, you can make just about anything happen (and luckily, thanks to many thousands of plugin developers, you can probably find it ready-made). [0]: https://stackoverflow.com/a/29953572/947478 https://stackoverflow.com/a/29953572/947478
- garciasn 5y agoIt isn’t silly nor did it require you to jump to the defense of vim’s behavior. It was a simple statement that vim’s functionality can be clunky and with all of its flexibility, it cannot handle something as simple as nano/pico’s method for keyboard copy/paste. It’s literally the one functionality I would love to become available in vim that exists in nano/pico which would make mine (and likely many others’) lives and efficiency better.
- maddyboo 5y agoBut it can handle it with a very small bit of configuration, as I’ve shown above. I am not trying to defend vim here, the editor you use or prefer has no effect on me. I’m just trying to point out that if you want it to work in a certain way, it’s almost always possible.