diff --git a/README.md b/README.md index ea4a068..0d463ba 100755 --- a/README.md +++ b/README.md @@ -36,26 +36,28 @@ This is the baseline list of commands supported in `ex-mode`. | Command | Operation | | --------------------------------------- | ---------------------------------- | -| `q/quit/tabc/tabclose` | Close active tab | -| `qall/quitall` | Close all tabs | -| `tabe/tabedit/tabnew` | Open new tab | -| `e/edit/tabe/tabedit/tabnew ` | Edit given file | -| `tabn/tabnext` | Go to next tab | -| `tabp/tabprevious` | Go to previous tab | -| `tabo/tabonly` | Close other tabs | -| `w/write` | Save active tab | -| `w/write/saveas ` | Save as | -| `wall/wa` | Save all tabs | -| `sp/split` | Split window | -| `sp/split ` | Open file in split window | -| `s/substitute` | Substitute regular expression in active line | -| `vsp/vsplit` | Vertical split window | -| `vsp/vsplit ` | Open file in vertical split window | -| `delete` | Cut active line | -| `yank` | Copy active line | -| `set ` | Set options | -| `sort` | Sort all lines in file | -| `sort ` | Sort lines in line range | +| `q/quit/tabc/tabclose` | Close active tab | +| `qall/quitall` | Close all tabs | +| `tabe/tabedit/tabnew` | Open new tab | +| `e/edit/tabe/tabedit/tabnew ` | Edit given file | +| `tabn/tabnext` | Go to next tab | +| `tabp/tabprevious` | Go to previous tab | +| `tabfir/tabfirst/tabr/tabrewind` | Go to the first tab | +| `tabl/tablast` | Go to the last tab | +| `tabo/tabonly` | Close other tabs | +| `w/write` | Save active tab | +| `w/write/saveas ` | Save as | +| `wall/wa` | Save all tabs | +| `sp/split` | Split window | +| `sp/split ` | Open file in split window | +| `s/substitute` | Substitute regular expression in active line | +| `vsp/vsplit` | Vertical split window | +| `vsp/vsplit ` | Open file in vertical split window | +| `delete` | Cut active line | +| `yank` | Copy active line | +| `set ` | Set options | +| `sort` | Sort all lines in file | +| `sort ` | Sort lines in line range | See `lib/ex.coffee` for the implementations of these commands. Contributions are very welcome! diff --git a/lib/ex.coffee b/lib/ex.coffee index b262023..c3ed2a6 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -173,6 +173,23 @@ class Ex tabp: => @tabprevious() + tabrewind: -> + pane = atom.workspace.getActivePane() + pane.activateItemAtIndex(0) + + tabr: => @tabrewind() + + tabfirst: => @tabrewind() + + tabfir: => @tabrewind() + + tablast: -> + pane = atom.workspace.getActivePane() + index = pane.getItems().length - 1 + pane.activateItemAtIndex(index) + + tabl: => @tablast() + tabonly: -> tabBar = atom.workspace.getPanes()[0] tabBarElement = atom.views.getView(tabBar).querySelector(".tab-bar") diff --git a/spec/ex-commands-spec.coffee b/spec/ex-commands-spec.coffee index 29f211e..0cf697d 100644 --- a/spec/ex-commands-spec.coffee +++ b/spec/ex-commands-spec.coffee @@ -444,6 +444,34 @@ describe "the commands", -> submitNormalModeInputText('tabprevious') expect(pane.getActiveItemIndex()).toBe(pane.getItems().length - 1) + describe ":tabfirst", -> + pane = null + beforeEach -> + waitsForPromise -> + pane = atom.workspace.getActivePane() + atom.workspace.open().then -> atom.workspace.open() + .then -> atom.workspace.open() + + it "switches to the first tab", -> + pane.activateItemAtIndex(2) + openEx() + submitNormalModeInputText('tabfirst') + expect(pane.getActiveItemIndex()).toBe(0) + + describe ":tablast", -> + pane = null + beforeEach -> + waitsForPromise -> + pane = atom.workspace.getActivePane() + atom.workspace.open().then -> atom.workspace.open() + .then -> atom.workspace.open() + + it "switches to the last tab", -> + pane.activateItemAtIndex(0) + openEx() + submitNormalModeInputText('tablast') + expect(pane.getActiveItemIndex()).toBe(2) + describe ":wq", -> beforeEach -> spyOn(Ex, 'write').andCallThrough()