Support tpope/vim-unimpaired
Is your feature request related to a problem? Please describe.
I really miss using my [ and ] to navigate through lists in vim. Obviously not all those lists translate directly, but I find that many of them do.
Describe the solution you'd like Emulate the behavior of tpope/vim-unimpaired.
Describe alternatives you've considered
I will begin implementing some of the functionality with keybindings.json.
I miss following [/] mappings from vim-unimpaired
[<space>/]<space>insert empty line above/below[e/]emoving lines around (I do not like the arrow based mappings from vscode)[q/]qgoing through the quickfix list/build errors: next problem/previous problem
However, I also would like to have the toggle mappings (if applicable), e.g.
yonline numbersyorrelative line numbers (see https://stackoverflow.com/questions/43597322)yowwrapping linesyosspell checking
A first try to define the unimpaired mappings [<space>, ]<space>, [e, ]e:
{
"vim.normalModeKeyBindings": [
{
"before": [ "[", " " ],
"after": [ "O", "<Esc>", "j", "0" ]
},
{
"before": [ "]", " " ],
"after": [ "o", "<Esc>", "k", "0" ]
},
{
"before": [ "]", "e" ],
"commands": [ "editor.action.moveLinesDownAction" ]
},
{
"before": [ "[", "e" ],
"commands": [ "editor.action.moveLinesUpAction" ]
}
],
"vim.visualModeKeyBindings": [
{
"before": [ "]", "e" ],
"commands": [ "editor.action.moveLinesDownAction" ]
},
{
"before": [ "[", "e" ],
"commands": [ "editor.action.moveLinesUpAction" ]
}
]
}
Dot-repeat does not work for [e and ]e.
I recently made the keybindings for the l ]q and [q (at lwast in context of the diff view). I would be interested in helping identify or verify others.
On Wed, Jan 6, 2021, 03:32 kiryph [email protected] wrote:
A first try to define the unimpaired mappings [
, ] , [e, ]e: { "vim.normalModeKeyBindings": [ { "before": [ "[", " " ], "after": [ "O", "<Esc>", "j", "0" ] }, { "before": [ "]", " " ], "after": [ "o", "<Esc>", "k", "0" ] }, { "before": [ "]", "e" ], "commands": [ "editor.action.moveLinesDownAction" ] }, { "before": [ "[", "e" ], "commands": [ "editor.action.moveLinesUpAction" ] } ], "vim.visualModeKeyBindings": [ { "before": [ "]", "e" ], "commands": [ "editor.action.moveLinesDownAction" ] }, { "before": [ "[", "e" ], "commands": [ "editor.action.moveLinesUpAction" ] } ] }
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/VSCodeVim/Vim/issues/3263#issuecomment-755189559, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBE2V22AU6F5YYXBKIXO2DSYQU2TANCNFSM4GKKHBEA .
@NGenetzky could you share your mappings?
I'm looking for:
- setting toggles (yoc, yon, yoh, ect)
- next previous problem
]l[l
Figured I would share this since it's related but actually part of vim-gitgutter
Move to the next/previous version control chunk in a file
// vim-gitgutter
{
"before": [ "]", "c" ],
"commands": [ "editor.action.dirtydiff.next" ]
},
{
"before": [ "[", "c" ],
"commands": [ "editor.action.dirtydiff.previous" ]
},
{
"before": [ "]", "c" ],
"commands": [ "workbench.action.compareEditor.nextChange" ]
},
{
"before": [ "[", "c" ],
"commands": [ "workbench.action.compareEditor.previousChange" ]
},
A few more for you here: (the last few are not standard in vim-unimpaired)
{ "before": [ "[", "b" ], "commands": [ "workbench.action.previousEditor" ] },
{ "before": [ "]", "b" ], "commands": [ "workbench.action.nextEditor" ] },
{ "before": [ "[", "f" ], "commands": [ "workbench.view.explorer", "list.focusUp", "explorer.openAndPassFocus" ] },
{ "before": [ "]", "f" ], "commands": [ "workbench.view.explorer", "list.focusDown", "explorer.openAndPassFocus" ] },
{ "before": [ "[", "q" ], "commands": [ "search.action.focusPreviousSearchResult" ], "when": "hasSearchResult" },
{ "before": [ "]", "q" ], "commands": [ "search.action.focusNextSearchResult" ], "when": "hasSearchResult" },
{ "before": [ "[", "r" ], "commands": [ "references-view.prev" ], "when": "reference-list.hasResult" },
{ "before": [ "]", "r" ], "commands": [ "references-view.next" ], "when": "reference-list.hasResult" },
{ "before": [ "[", "l" ], "commands": [ "editor.action.marker.prevInFiles" ], "when": "editorTextFocus" },
{ "before": [ "]", "l" ], "commands": [ "editor.action.marker.nextInFiles" ], "when": "editorTextFocus" },
{ "before": [ "[", "g" ], "commands": [ "workbench.action.editor.previousChange" ], "when": "editorTextFocus" },
{ "before": [ "]", "g" ], "commands": [ "workbench.action.editor.nextChange" ], "when": "editorTextFocus" },
{ "before": [ "[", "w" ], "commands": [ "workbench.action.focusPreviousGroup" ] },
{ "before": [ "]", "w" ], "commands": [ "workbench.action.focusNextGroup" ] },
From my settings.json file.
This is what I use for diff
{ "before": ["y", "o", "d"], "commands": ["git.openChange"] }
I'm not sure how to toggle it. Return to the current state of the file and close diff
Some more, looks like we are getting close!
{
// like `:set wrap!`
"before": ["y", "o", "w"],
"commands": ["editor.action.toggleWordWrap"],
},
{
// like `:set listchars!`
"before": ["y", "o", "l"],
"commands": ["editor.action.toggleRenderWhitespace"],
},
{
// If you set a "workbench.preferredDarkColorTheme", and a
// "workbench.preferredLightColorTheme", `yob` will toggle between them,
// otherwise it toggles between VSCode's Default Light+/Dark+ themes
"before": ["y", "o", "b"],
"commands": ["workbench.action.toggleLightDarkThemes"],
},
{
// cSpell has different options for workspace vs global here
"before": ["y", "o", "s"],
"commands": ["cSpell.toggleEnableSpellChecker"],
},
@NGenetzky could you share your mappings?
I'm looking for:
* setting toggles (yoc, yon, yoh, ect) * next previous problem `]l` `[l`Figured I would share this since it's related but actually part of vim-gitgutter
Move to the next/previous version control chunk in a file
// vim-gitgutter { "before": [ "]", "c" ], "commands": [ "editor.action.dirtydiff.next" ] }, { "before": [ "[", "c" ], "commands": [ "editor.action.dirtydiff.previous" ] }, { "before": [ "]", "c" ], "commands": [ "workbench.action.compareEditor.nextChange" ] }, { "before": [ "[", "c" ], "commands": [ "workbench.action.compareEditor.previousChange" ] },
I noticed that if i have a buffer open with split screen looking at the compareEditor then the [ c binding causes a jump. Maybe a when condition is needed.
A first try to define the unimpaired mappings
[<space>,]<space>,[e,]e: [...] { "before": [ "[", " " ], "after": [ "O", "<Esc>", "j", "0" ] }, { "before": [ "]", " " ], "after": [ "o", "<Esc>", "k", "0" ] },
@kiryph I used ^ instead of 0 as vim goes to the first character of the line instead of the beginning of the line. Weirdly, neovim stays in the same position, but that behavior is also doable:
{
"before": [ "[", " " ],
"after": ["m", "z", "O", "<Esc>", "`", "z"]
},
{
"before": [ "]", " " ],
"after": ["m", "z", "o", "<Esc>", "`", "z"]
},
m saves the cursor position, and the backtick goes back to it (single quote only goes back to the cursor's line, not to its exact position)
EDIT:
I am having issues with [ , I think somehow mz doesn't update the position of the mark after adding the line above with O (even though that works when testing manually), so I had to use the much weirder
"after": ["m", "z", "y", "y", "p", "`", "z", "j", "m", "z", "k", "0", "d", "$", "`", "z"]
in a nut shell, mark position, duplicate line below, go back to exact position, go one line down, mark new position, go one line up, delete whole line, go back to position. Bit of an over-engineered bummer, but I couldn't make it work any other way while keeping the position.