onivim / oni2

Native, lightweight modal code editor
https://v2.onivim.io
MIT License
7.84k stars 282 forks source link

Keybinding Suggestions and Contribution Opportunities #1423

Open glennsl opened 4 years ago

glennsl commented 4 years ago

This is the place to be if you want to suggest a keybinding, or find a nice and (usually) easy task to start contributing.

Suggestions

Name Command/
Default
Assignee/
PR/Issue
:heavy_check_mark: ~Save~ workbench.action.files.save
Mod+S
@jakeday
#1426
Focus Tab # workbench.action.openEditorAtIndex[1-9]
Mod+1 - Mod+9
@leavengood
:heavy_check_mark: ~Previous Tab~ workbench.action.previousEditor
Mod+PgUp / Cmd+Shift+[
@leavengood
#778/#1447
:heavy_check_mark: ~Next Tab~ workbench.action.nextEditor
Mod+PgDn / Cmd+Shift+]
@leavengood
#778/#1447
Copy input.copy?
Mod+C
@fanantoxa
#1233
Cut input.cut?
Mod+X
@fanantoxa
#1233
Paste input.paste?
Mod+V
@fanantoxa
#1233
Go to next error editor.action.marker.nextInFiles
F8
#1349
Go to previous error editor.action.marker.prevInFiles
Shift + F8
#1349
Go to next search result search.action.focusNextSearchResult
F4
Go to previous search result search.action.focusPreviousSearchResult
Shift + F4
Open settings workbench.action.openSettings
Cmd+,
:heavy_check_mark: ~Zoom In~ workbench.action.zoomIn
Ctrl++
@ArtemDrozdov
#1556/#1629
:heavy_check_mark: ~Zoom Out~ workbench.action.zoomOut
Ctrl+-
@ArtemDrozdov
#1556/#1629
:heavy_check_mark: ~Zoom Reset~ workbench.action.zoomReset
Ctrl+0
@ArtemDrozdov
#1556/#1629

Do you have other suggestions? Post a comment below! If the keybinding exists in vscode as well, it would be nice if you could post the name, command and default keybinding used there.

How to contribute

Keybindings are defined in KeyBindingsStoreConnector. Here's the keybinding for unfo, for example:

https://github.com/onivim/oni2/blob/bb2df4cd5d88a4f7e643e1f6b849c0b50ad87874/src/Store/KeyBindingsStoreConnector.re#L162-L166

When invoked this will generate a Command("undo") action, which needs to be handled in a Store somewhere. The undo comamnd is handled in VimStoreConnector here:

https://github.com/onivim/oni2/blob/bb2df4cd5d88a4f7e643e1f6b849c0b50ad87874/src/Store/VimStoreConnector.re#L855

Which invokes the effect defined a bit further up, here:

https://github.com/onivim/oni2/blob/bb2df4cd5d88a4f7e643e1f6b849c0b50ad87874/src/Store/VimStoreConnector.re#L827-L834

A lot of keybindings will be like this, just delegating to libvim to handle it. Some might require a bit more though, but a good place to start is to look into how this is done and vim, and whether it can be delegated in the same manner as this.

If you feel ready to tackle one of the suggestions above, post a comment below to lets us know, then dive in! If you have questions, the best place to ask is in the #dev channel on our Discord server.

irevived1 commented 4 years ago

Hello, would be nice if we have something like vim-tmux-navigator which allows user to seamlessly navigate through vim splits/terminals/file trees via ctrl+(h,j,k,l)

would also be nice to alias j and k to down and up for non-input fields too.

thanks for welcoming suggestions!

fanantoxa commented 4 years ago

@glennsl Select All already implemented with Selection PR

escorponox commented 4 years ago

I would like to be able to "kind of import" my mappings from init.vim regarding tabs and splits.

" windows
nnoremap ,z <C-W>\|
nnoremap ,h <C-W>h
nnoremap ,j <C-W>j
nnoremap ,k <C-W>k
nnoremap ,l <C-W>l
nnoremap ,= <C-W>=
nnoremap ,x <C-W>x
nnoremap ,c :close<CR>

" tabs
nnoremap ,tg :tabnew<CR>
nnoremap ,tt :tabn<CR>
nnoremap ,tr :tabc<CR>
nnoremap ,tp :tabp<CR>
glennsl commented 4 years ago

@irevived1 Yeah, that's definitely planned, although probably using Ctrl+W - h/j/k/l. It's a feature that require significantly more work than just adding some keybindings though, since at the moment we have no concept of where parts of the UI are relative to each other. I don't think there's an issue for it, but we have it noted down elsewhere and it's on the top of our minds since it's an essential part of the UX we're aiming for.

@fanantoxa Oh, lol, of course. I just use it all the time! Removed from the list.

@escorponox There's already experimental support for VimL, including remapping. See https://onivim.github.io/docs/configuration/settings#experimental

jakeday commented 4 years ago

@glennsl The save request is handled via #1426 and is good to go!

glennsl commented 4 years ago

Thanks @jakeday. Noted.

leavengood commented 4 years ago

The VSCode actions for focusing tabs by number is workbench.action.openEditorAtIndex[1-9]. And there are key bindings for Ctrl-[num] and Cmd-[num] (on macOS at least.)

I think I will look into adding this and the nextEditor/previousEditor commands.

I will probably will make a loop for defining the commands and key bindings for the numbered ones, and then map those to :b1-:b9. Also :bnext and :bprevious don't seem to be implemented yet, so it might make sense to implement those and just connect nextEditor/previousEditor to them. I don't yet know how to do that though.

glennsl commented 4 years ago

Thanks @leavengood. I've updated the OP and assigned you to those.

Also :bnext and :bprevious don't seem to be implemented yet

I think they are, but they're pretty broken? No idea what the problem might be though. Maybe @bryphe has some ideas.

jakeday commented 4 years ago

I added #1450 for indenting and outdenting with tab and shift tab when in visual mode. Let me know if I need to change anything!

CrossR commented 4 years ago

It'd be nice for the keybinding docs to be updated as well (and then kept up to date with any changes from this issue).

There is a complete list here https://github.com/onivim/oni2/blob/master/src/Store/KeyBindingsStoreConnector.re, which could be used to fill in any default bindings and missing conditions for the documentation.

The website file lives here: https://github.com/onivim/oni2/blob/master/docs/docs/configuration/key-bindings.md

igniscyan commented 4 years ago

Is there any way we could get an Xcode-like minimap mark feature? Example here
image

glennsl commented 4 years ago

It's been brought up before, but I can't find that there's any existing issues for it. You should create one for it. It's a cool feature. I can't see how it relates to keybindings though.

lettertwo commented 4 years ago

Does the file explorer currently support keybindings? In vscode, i find it natural to map h,j,k,l to move between files and directories in the explorer tree. Is this a possible configuration for Oni yet, and if not, is it a roadmap or desirable feature?

Edit: Should've searched issues more before commenting 🤦 https://github.com/onivim/oni2/issues/528

schinns commented 4 years ago

It would be nice when you are in Search to be able to select all the text. Perhaps Cmd + a?

Happy to take a stab at this, if there isn't someone assigned to this already.

fanantoxa commented 4 years ago

@benschinn There already a implemented. Ctrl + A works on linux/window on all inputs (like Ctrl+P, file search, git, etc) it uses binding <C-a> so it might be working already, if it not please create an issue (I don't have any mac to check)

jamischarles commented 4 years ago

Hey folks. Bought onivim today and loving it so far. Trying to customize everything like I have in neovim.

Current problem I'm seeing: "nnoremap <Space>d YP" I'm trying to have space+d duplicate the current line, or current selection, but this doesn't seem to work at all using experimental.viml

I see that VSCode has support for editor.action.copyLinesDownAction and many other actions here: https://code.visualstudio.com/docs/getstarted/keybindings.

What level of feature parity between VSCode and these actions are we expecting onivim to support?

A few suggestions:

  1. Could we have key remapping available in the keybindings file, given that many of the actions from VSCode aren't available? That could solve my problem above I'm having.
  2. If we plan to support experimental.viml longer term, could we support the editor actions in that? ie: nnoremap <space>w :workbench.action.files.save
  3. Could we add support for "editor.action.commentLine", which would toggle a comment line?
  4. Any chance we could have workbench.action.nextEditor cycle back to beginning when it's reached the end? Same for previousEditor going the other way.
  5. Add support for open last buffer. (most recently visited)

Keep up the great work! Happy to issue PRs for any of these if they aren't too difficult.

reyzavk commented 4 years ago

I'd love to see the spacevim/spacemacs majestic keybind #756 I think having space keybind combined with VSC support will increase the value of onivim. Both spacemacs and vscode vim emulation have their own drawbacks. And I think oni2 can strike a good balance between them. It's a juicy market of people who wants VSC power but want the efficient keybind of modal editing.

anyway I appreciate you guys for your hard work I don't hesitate in buying for second time if oni2 can deliver :)

AkechiShiro commented 4 years ago

I have not found a way to bind a key to close a file/tab, even looking in the file that should have all the keybindings maybe I didn't look thoroughly enough ? Could someone perhaps tell me where I should be looking or is this not implemented yet as a keybinding and would require a PR ?

jamischarles commented 4 years ago

@AkechiShiro took me a long time but this is the command {"key": "<space>q", "command": "view.closeEditor", "when": "normalMode && editorTextFocus" },

Th3Whit3Wolf commented 4 years ago

I'm a big fan of using enter for completion and / to move through suggestion. This actually easier to set in vim than in vim with some autocompletion plugins.

{
      "key":"<S-Tab>",
      "command":"selectPrevSuggestion",
      "when":"editorTextFocus && suggestWidgetVisible"
   },
   {
      "key":"<Tab>",
      "command":"selectNextSuggestion",
      "when":"editorTextFocus && suggestWidgetVisible"
   },
   {
      "key":"<CR>",
      "command":"acceptSelectedSuggestion",
      "when":"suggestWidgetVisible && editorTextFocus"
   }
Th3Whit3Wolf commented 4 years ago

I think it would be cool if there was a list of all possible values for command so that someone could make a mapping.vim => keybindings.json webapp.

spar7453 commented 4 years ago

I wish :enew or "workbench.action.files.newUntitledFile" is implemented in keybindings Also, how can I set key bindings when I am focusing on FileExplorer? I tried to find something like listFocus, but could not find one.

glennsl commented 4 years ago

@spar7453: You can bind to :enew: https://onivim.github.io/docs/configuration/key-bindings#ex-commands

spar7453 commented 4 years ago

@glennsl I tried to bind as the following { "key": "< space>fn", "command": ":enew", when: "normalMode" } and it did not work.

I think that we cannot bind every vim commands in this way and also waiting for binding { "key": "< space>b1", "command": ":b2", when: "normalMode" }

(I had to put empty space in front of "s" because the editor removes "< space>")

glennsl commented 4 years ago

@spar7453 Yeah that does seem broken. When trying it myself I can see from the logs that it's running the command, but then nothing happens. I've created #2604 to track it.

RilDev commented 3 years ago

How about Ctrl+] to toggle the terminal windows? As suggested here: https://discordapp.com/channels/417774914645262338/424012160696582144/785130754446327809

Is there a way we could bind the command :term ++curwin tmux to Ctrl+]?

marcinkoziej commented 3 years ago

The issue should be updated to link to src/Model/State.re for list of all key bindings

Szune commented 3 years ago

Is #1349 "Go to next error" done? Otherwise I might take a look at it this weekend, would be fun to get into the codebase and start contributing.

bryphe commented 3 years ago

Hi @Szune ,

Go to next error is not implemented yet - it would be awesome to have though! I find myself wanting it all the time 😄 Let me know if you need help getting started

Szune commented 3 years ago

Cool @bryphe , I'll try to get started on it when I wake up later today 😃

Is there anything I should look at other than https://onivim.github.io/docs/for-developers/contributing before beginning?

goetzc commented 3 years ago

I would like to have this working, to be able to use C-j and C-k to navigate in the Quick Open dialog:

// Quick Open
{ "key": "ctrl+k", "command": "workbench.action.quickOpenSelectPrevious", "when": "inQuickOpen" },
{ "key": "ctrl+j", "command": "workbench.action.quickOpenSelectNext", "when": "inQuickOpen" },
lettertwo commented 3 years ago

@goetzc How about:

  {"key": "ctrl+k", "command": "list.focusUp", "when": "inQuickOpen"},
  {"key": "ctrl+j", "command": "list.focusDown", "when": "inQuickOpen"},

or, to use the same in any list view:

  {"key": "ctrl+k", "command": "list.focusUp", "when": "listFocus"},
  {"key": "ctrl+j", "command": "list.focusDown", "when": "listFocus"},
goetzc commented 3 years ago

@lettertwo that works perfect, thank you!

LiHRaM commented 3 years ago

Seems like the "Open settings" keybinding is not being worked on yet, so I'll gladly get started on that. :smile:

rambip commented 3 years ago

I think the brackets/surroundings of the plugin surround.vim are so great they should be on by default: the nice thing is that they don't conflict with vim keys ! And make sure the "delete brackets" commands are repeatable ! The keys used by doom-emacs are really well made, it would be nice to have some of them too ! In particular vim-sneak.

lougreenwood commented 3 years ago

@rambip is it possible to use surround.vim with Oni2 at the moment? I didn't see that yet...?

ninjabreakbot commented 3 years ago

Just found this issue and want to move by open issue to this comment and close it, also going to review info provided to see how this might be resolved. Leaving my comments below to see if anyone has already resolved or dealt with this.

Two items strike me as usability issues for myself and I wanted to welcome any comments on resolving or agreeing with their existence.

EDIT: I've just noticed that the use of :term is opening a terminal in a pane, and control + ` is opening the terminal in a fashion more in line with that was expected. Rather then what I note in (item 1) i would ask, why would these differ. Fine with both existing, but using :term i certainly assumed it would open the terminal seen when pressing control + `

Item 1 Common shortcut for previous commands entered at the command line is control + p. This however opens the file selection pallet when entered with the terminal in focus. Additionally pressing command + p opens this same pallet. It should be noted that once in the pallet you can navigate using control + p / command + p and control + n / command + n.

Item 2 Open terminal, then opening a file places new file in the terminal pane area, replacing your view of the terminal.

Thank you.

weirdan commented 3 years ago

I'd like to add a couple of suggestions:

Ding-Fan commented 3 years ago

I wish Ctrl + / as toggle comments(single & multi line)