Conversation
…oving around windows
| -- Move current line/s under cursor up or down | ||
| vim.keymap.set("n", "J", ":m .+1<CR>==", { desc = "Move current line down" }) | ||
| vim.keymap.set("n", "K", ":m .-2<CR>==", { desc = "Move current line up" }) | ||
| vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move current line down" }) | ||
| vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move current line up" }) |
There was a problem hiding this comment.
@grzuy Tried this using <C-up/donw> but seems that this it's a mac keybinding. We should check which behavior do we want here, Overriding mac's keybindings or use another one
There was a problem hiding this comment.
Gotcha, good call.
We need to find some other mapping though, K is now default for LSP hover documention.
There was a problem hiding this comment.
Maybe we can go with <A-j> and <A-k> like in the examples in https://vim.fandom.com/wiki/Moving_lines_up_or_down#Mappings_to_move_lines ?
There was a problem hiding this comment.
I found that using "Alt" on Mac can be really tricky, and we should allow some terminal emulators (iterm2, kitty, etc) to allow the use of it, Im thinking which others kemaps we can use for these
There was a problem hiding this comment.
https://stackoverflow.com/questions/9450905/how-to-bind-vim-through-tmux-to-cmd-key/9451636#9451636
If we can't find a good workaround, maybe the most sane option is to use <Leader>.
There was a problem hiding this comment.
Since seems that we can't use
<C-Up/Down>because of terminal remaps.J/Kbecause we have already a remap forK<C-j/k>because we have another PR that introduce moving around windows with those remaps
Another alternative can be <S-Up/Down>. We can also try with leader as you mentioned
There was a problem hiding this comment.
<S-Up/Down> is already taken by nvim to scroll window.
Can be seen with :help <S-Up>.
There was a problem hiding this comment.
Would the same workaround from LazyVim/LazyVim#2571 make <A-j> and <A-k> work for you also?
If so, maybe we can go with that and use the same keymaps LazyVim uses.
| -- Move current line/s under cursor up or down | ||
| vim.keymap.set("n", "J", ":m .+1<CR>==", { desc = "Move current line down" }) | ||
| vim.keymap.set("n", "K", ":m .-2<CR>==", { desc = "Move current line up" }) | ||
| vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move current line down" }) | ||
| vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move current line up" }) |
There was a problem hiding this comment.
Gotcha, good call.
We need to find some other mapping though, K is now default for LSP hover documention.
| @@ -0,0 +1,11 @@ | |||
| -- Move current line/s under cursor up or down | |||
| vim.keymap.set("n", "J", ":m .+1<CR>==", { desc = "Move current line down" }) | |||
| vim.keymap.set("n", "K", ":m .-2<CR>==", { desc = "Move current line up" }) | |||
There was a problem hiding this comment.
Very nice!
This coming from https://vim.fandom.com/wiki/Moving_lines_up_or_down?
We could add the source in a comment, given it has good explanation for the mappings.
|
Conflicts in README after I merged #4 , sorry bout that 😝 |
|
solved conflits with |
This pull request includes: