4 ms·
Forgive 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
by maddyboo 5y ago
Forgive 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.