@@ -2240,11 +2240,6 @@ pub fn hover(cx: &mut Context) {
22402240 );
22412241}
22422242
2243−// view movements
2244−pub fn next_view(cx: &mut Context) {
2245− cx.editor.focus_next()
2246−}
2247−
22482243// comments
22492244pub fn toggle_comments(cx: &mut Context) {
22502245 let (view, doc) = cx.current();
@@ -2308,16 +2303,38 @@ pub fn jump_backward(cx: &mut Context) {
23082303 };
23092304}
23102305
2311−//
2306+pub fn window_mode(cx: &mut Context) {
2307+ cx.on_next_key(move |cx, event| {
2308+ if let KeyEvent {
2309+ code: KeyCode::Char(ch),
2310+ ..
2311+ } = event
2312+ {
2313+ match ch {
2314+ 'w' => rotate_view(cx),
2315+ 'h' => hsplit(cx),
2316+ 'v' => vsplit(cx),
2317+ 'q' => wclose(cx),
2318+ _ => {}
2319+ }
2320+ }
2321+ })
2322+}
23122323
2313−pub fn vsplit(cx: &mut Context) {
2324+pub fn rotate_view(cx: &mut Context) {
2325+ cx.editor.focus_next()
2326+}
2327+
2328+// split helper, clear it later
2329+use helix_view::editor::Action;
2330+fn split(cx: &mut Context, action: Action) {
23142331 use helix_view::editor::Action;
23152332 let (view, doc) = cx.current();
23162333 let id = doc.id();
23172334 let selection = doc.selection(view.id).clone();
23182335 let first_line = view.first_line;
23192336
2320− cx.editor.switch(id, Action::VerticalSplit);
2337+ cx.editor.switch(id, action);
23212338
23222339 // match the selection in the previous view
23232340 let (view, doc) = cx.current();
@@ -2325,6 +2342,20 @@ pub fn vsplit(cx: &mut Context) {
23252342 doc.set_selection(view.id, selection);
23262343}
23272344
2345+pub fn hsplit(cx: &mut Context) {
2346+ split(cx, Action::HorizontalSplit);
2347+}
2348+
2349+pub fn vsplit(cx: &mut Context) {
2350+ split(cx, Action::VerticalSplit);
2351+}
2352+
2353+pub fn wclose(cx: &mut Context) {
2354+ let view_id = cx.view().id;
2355+ // close current split
2356+ cx.editor.close(view_id, /* close_buffer */ false);
2357+}
2358+
23282359pub fn space_mode(cx: &mut Context) {
23292360 cx.on_next_key(move |cx, event| {
23302361 if let KeyEvent {
@@ -2336,18 +2367,12 @@ pub fn space_mode(cx: &mut Context) {
23362367 match ch {
23372368 'f' => file_picker(cx),
23382369 'b' => buffer_picker(cx),
2339− 'v' => vsplit(cx),
23402370 'w' => {
23412371 // save current buffer
23422372 let (view, doc) = cx.current();
23432373 doc.format(view.id); // TODO: merge into save
23442374 tokio::spawn(doc.save());
23452375 }
2346− 'c' => {
2347− let view_id = cx.view().id;
2348− // close current split
2349− cx.editor.close(view_id, /* close_buffer */ false);
2350− }
23512376 // ' ' => toggle_alternate_buffer(cx),
23522377 // TODO: temporary since space mode took it's old key
23532378 ' ' => keep_primary_selection(cx),