Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I try to not stray too far from the default key binding as I think it would be good to be able to use Vim on servers that don't have all my config. But, hey, what's the point of using Vim if you're not having fun ricing it? These are some indispensable key maps to me:

In visual mode, move a line up or down: vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv") vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")

In normal mode, replace all occurences of the word under the cursor: vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])

In normal or visual mode, Yank to the OS's pasteboard: vim.keymap.set({"n", "v"}, "<leader>y", [["+y]])

And there are plenty more that are related to specific plugins.

Also, I've remapped caps lock to esc in the OS. This makes it way easier to leave insert mode without leaving the home row.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: