mirror of https://github.com/helix-editor/helix
parent
212f6bc372
commit
8c2fa12ffc
|
@ -24,13 +24,13 @@
|
||||||
| PageDown | Move page down |
|
| PageDown | Move page down |
|
||||||
| ctrl-u | Move half page up |
|
| ctrl-u | Move half page up |
|
||||||
| ctrl-d | Move half page down |
|
| ctrl-d | Move half page down |
|
||||||
| Tab | Switch to next view |
|
|
||||||
| ctrl-i | Jump forward on the jumplist TODO: conflicts tab |
|
| ctrl-i | Jump forward on the jumplist TODO: conflicts tab |
|
||||||
| ctrl-o | Jump backward on the jumplist |
|
| ctrl-o | Jump backward on the jumplist |
|
||||||
| v | Enter select (extend) mode |
|
| v | Enter select (extend) mode |
|
||||||
| g | Enter goto mode |
|
| g | Enter goto mode |
|
||||||
| : | Enter command mode |
|
| : | Enter command mode |
|
||||||
| z | Enter view mode |
|
| z | Enter view mode |
|
||||||
|
| ctrl-w | Enter window mode |
|
||||||
| space | Enter space mode |
|
| space | Enter space mode |
|
||||||
| K | Show documentation for the item under the cursor |
|
| K | Show documentation for the item under the cursor |
|
||||||
|
|
||||||
|
@ -132,6 +132,17 @@ Jumps to various locations.
|
||||||
|
|
||||||
TODO: Mappings for selecting syntax nodes (a superset of `[`).
|
TODO: Mappings for selecting syntax nodes (a superset of `[`).
|
||||||
|
|
||||||
|
## Window mode
|
||||||
|
|
||||||
|
This layer is similar to vim keybindings as kakoune does not support window.
|
||||||
|
|
||||||
|
| Key | Description |
|
||||||
|
|-----|-------------|
|
||||||
|
| w, ctrl-w | Switch to next window |
|
||||||
|
| v, ctrl-v | Vertical right split |
|
||||||
|
| h, ctrl-h | Horizontal bottom split |
|
||||||
|
| q, ctrl-q | Close current window |
|
||||||
|
|
||||||
## Space mode
|
## Space mode
|
||||||
|
|
||||||
This layer is a kludge of mappings I had under leader key in neovim.
|
This layer is a kludge of mappings I had under leader key in neovim.
|
||||||
|
@ -140,7 +151,5 @@ This layer is a kludge of mappings I had under leader key in neovim.
|
||||||
|-----|-----------|
|
|-----|-----------|
|
||||||
| f | Open file picker |
|
| f | Open file picker |
|
||||||
| b | Open buffer picker |
|
| b | Open buffer picker |
|
||||||
| v | Open a new vertical split into the current file |
|
|
||||||
| w | Save changes to file |
|
| w | Save changes to file |
|
||||||
| c | Close the current split |
|
|
||||||
| space | Keep primary selection TODO: it's here because space mode replaced it |
|
| space | Keep primary selection TODO: it's here because space mode replaced it |
|
||||||
|
|
|
@ -2240,11 +2240,6 @@ pub fn hover(cx: &mut Context) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// view movements
|
|
||||||
pub fn next_view(cx: &mut Context) {
|
|
||||||
cx.editor.focus_next()
|
|
||||||
}
|
|
||||||
|
|
||||||
// comments
|
// comments
|
||||||
pub fn toggle_comments(cx: &mut Context) {
|
pub fn toggle_comments(cx: &mut Context) {
|
||||||
let (view, doc) = cx.current();
|
let (view, doc) = cx.current();
|
||||||
|
@ -2308,16 +2303,38 @@ pub fn jump_backward(cx: &mut Context) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
pub fn window_mode(cx: &mut Context) {
|
||||||
|
cx.on_next_key(move |cx, event| {
|
||||||
|
if let KeyEvent {
|
||||||
|
code: KeyCode::Char(ch),
|
||||||
|
..
|
||||||
|
} = event
|
||||||
|
{
|
||||||
|
match ch {
|
||||||
|
'w' => rotate_view(cx),
|
||||||
|
'h' => hsplit(cx),
|
||||||
|
'v' => vsplit(cx),
|
||||||
|
'q' => wclose(cx),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn vsplit(cx: &mut Context) {
|
pub fn rotate_view(cx: &mut Context) {
|
||||||
|
cx.editor.focus_next()
|
||||||
|
}
|
||||||
|
|
||||||
|
// split helper, clear it later
|
||||||
|
use helix_view::editor::Action;
|
||||||
|
fn split(cx: &mut Context, action: Action) {
|
||||||
use helix_view::editor::Action;
|
use helix_view::editor::Action;
|
||||||
let (view, doc) = cx.current();
|
let (view, doc) = cx.current();
|
||||||
let id = doc.id();
|
let id = doc.id();
|
||||||
let selection = doc.selection(view.id).clone();
|
let selection = doc.selection(view.id).clone();
|
||||||
let first_line = view.first_line;
|
let first_line = view.first_line;
|
||||||
|
|
||||||
cx.editor.switch(id, Action::VerticalSplit);
|
cx.editor.switch(id, action);
|
||||||
|
|
||||||
// match the selection in the previous view
|
// match the selection in the previous view
|
||||||
let (view, doc) = cx.current();
|
let (view, doc) = cx.current();
|
||||||
|
@ -2325,6 +2342,20 @@ pub fn vsplit(cx: &mut Context) {
|
||||||
doc.set_selection(view.id, selection);
|
doc.set_selection(view.id, selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn hsplit(cx: &mut Context) {
|
||||||
|
split(cx, Action::HorizontalSplit);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn vsplit(cx: &mut Context) {
|
||||||
|
split(cx, Action::VerticalSplit);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn wclose(cx: &mut Context) {
|
||||||
|
let view_id = cx.view().id;
|
||||||
|
// close current split
|
||||||
|
cx.editor.close(view_id, /* close_buffer */ false);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn space_mode(cx: &mut Context) {
|
pub fn space_mode(cx: &mut Context) {
|
||||||
cx.on_next_key(move |cx, event| {
|
cx.on_next_key(move |cx, event| {
|
||||||
if let KeyEvent {
|
if let KeyEvent {
|
||||||
|
@ -2336,18 +2367,12 @@ pub fn space_mode(cx: &mut Context) {
|
||||||
match ch {
|
match ch {
|
||||||
'f' => file_picker(cx),
|
'f' => file_picker(cx),
|
||||||
'b' => buffer_picker(cx),
|
'b' => buffer_picker(cx),
|
||||||
'v' => vsplit(cx),
|
|
||||||
'w' => {
|
'w' => {
|
||||||
// save current buffer
|
// save current buffer
|
||||||
let (view, doc) = cx.current();
|
let (view, doc) = cx.current();
|
||||||
doc.format(view.id); // TODO: merge into save
|
doc.format(view.id); // TODO: merge into save
|
||||||
tokio::spawn(doc.save());
|
tokio::spawn(doc.save());
|
||||||
}
|
}
|
||||||
'c' => {
|
|
||||||
let view_id = cx.view().id;
|
|
||||||
// close current split
|
|
||||||
cx.editor.close(view_id, /* close_buffer */ false);
|
|
||||||
}
|
|
||||||
// ' ' => toggle_alternate_buffer(cx),
|
// ' ' => toggle_alternate_buffer(cx),
|
||||||
// TODO: temporary since space mode took it's old key
|
// TODO: temporary since space mode took it's old key
|
||||||
' ' => keep_primary_selection(cx),
|
' ' => keep_primary_selection(cx),
|
||||||
|
|
|
@ -264,10 +264,7 @@ pub fn default() -> Keymaps {
|
||||||
ctrl!('u') => commands::half_page_up,
|
ctrl!('u') => commands::half_page_up,
|
||||||
ctrl!('d') => commands::half_page_down,
|
ctrl!('d') => commands::half_page_down,
|
||||||
|
|
||||||
KeyEvent {
|
ctrl!('w') => commands::window_mode,
|
||||||
code: KeyCode::Tab,
|
|
||||||
modifiers: KeyModifiers::NONE
|
|
||||||
} => commands::next_view,
|
|
||||||
|
|
||||||
// move under <space>c
|
// move under <space>c
|
||||||
ctrl!('c') => commands::toggle_comments,
|
ctrl!('c') => commands::toggle_comments,
|
||||||
|
|
Loading…
Reference in New Issue