@@ -262,6 +262,8 @@ impl Command {
262262 goto_prev_diag, "Goto previous diagnostic",
263263 goto_line_start, "Goto line start",
264264 goto_line_end, "Goto line end",
265+ goto_next_buffer, "Goto next buffer",
266+ goto_previous_buffer, "Goto previous buffer",
265267 // TODO: different description ?
266268 goto_line_end_newline, "Goto line end",
267269 goto_first_nonwhitespace, "Goto first non-blank in line",
@@ -519,6 +521,33 @@ fn goto_line_start(cx: &mut Context) {
519521 )
520522}
521523
524+fn goto_next_buffer(cx: &mut Context) {
525+ goto_buffer(cx, Direction::Forward);
526+}
527+
528+fn goto_previous_buffer(cx: &mut Context) {
529+ goto_buffer(cx, Direction::Backward);
530+}
531+
532+fn goto_buffer(cx: &mut Context, direction: Direction) {
533+ let buf_cur = current!(cx.editor).1.id();
534+
535+ if let Some(pos) = cx.editor.documents.iter().position(|(id, _)| id == buf_cur) {
536+ let goto_id = if direction == Direction::Forward {
537+ if pos < cx.editor.documents.iter().count() - 1 {
538+ cx.editor.documents.iter().nth(pos + 1).unwrap().0
539+ } else {
540+ cx.editor.documents.iter().next().unwrap().0
541+ }
542+ } else if pos > 0 {
543+ cx.editor.documents.iter().nth(pos - 1).unwrap().0
544+ } else {
545+ cx.editor.documents.iter().last().unwrap().0
546+ };
547+ cx.editor.switch(goto_id, Action::Replace);
548+ }
549+}
550+
522551fn extend_to_line_start(cx: &mut Context) {
523552 let (view, doc) = current!(cx.editor);
524553 goto_line_start_impl(view, doc, Movement::Extend)