@@ -262,6 +262,8 @@ impl Command {
262 goto_prev_diag, "Goto previous diagnostic",
262 goto_prev_diag, "Goto previous diagnostic",
263 goto_line_start, "Goto line start",
263 goto_line_start, "Goto line start",
264 goto_line_end, "Goto line end",
264 goto_line_end, "Goto line end",
265+ goto_next_buffer, "Goto next buffer",
266+ goto_previous_buffer, "Goto previous buffer",
265 // TODO: different description ?
267 // TODO: different description ?
266 goto_line_end_newline, "Goto line end",
268 goto_line_end_newline, "Goto line end",
267 goto_first_nonwhitespace, "Goto first non-blank in line",
269 goto_first_nonwhitespace, "Goto first non-blank in line",
@@ -519,6 +521,33 @@ fn goto_line_start(cx: &mut Context) {
524+fn goto_next_buffer(cx: &mut Context) {
525+ goto_buffer(cx, Direction::Forward);
528+fn goto_previous_buffer(cx: &mut Context) {
529+ goto_buffer(cx, Direction::Backward);
532+fn goto_buffer(cx: &mut Context, direction: Direction) {
533+ let buf_cur = current!(cx.editor).1.id();
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
540+ cx.editor.documents.iter().next().unwrap().0
543+ cx.editor.documents.iter().nth(pos - 1).unwrap().0
545+ cx.editor.documents.iter().last().unwrap().0
547+ cx.editor.switch(goto_id, Action::Replace);
522fn extend_to_line_start(cx: &mut Context) {
551fn extend_to_line_start(cx: &mut Context) {
523 let (view, doc) = current!(cx.editor);
552 let (view, doc) = current!(cx.editor);
524 goto_line_start_impl(view, doc, Movement::Extend)
553 goto_line_start_impl(view, doc, Movement::Extend)