diff --git a/keymaps/vim-mode.cson b/keymaps/vim-mode.cson index aac4b4d2..d44c7dcc 100644 --- a/keymaps/vim-mode.cson +++ b/keymaps/vim-mode.cson @@ -105,6 +105,10 @@ 'ctrl-w c': 'pane:close' 'ctrl-w ctrl-q': 'core:close' 'ctrl-w q': 'core:close' + 'ctrl-w H': 'vim-mode:move-pane-view-to-far-left' + 'ctrl-w L': 'vim-mode:move-pane-view-to-far-right' + 'ctrl-w K': 'vim-mode:move-pane-view-to-very-top' + 'ctrl-w J': 'vim-mode:move-pane-view-to-very-bottom' 'g t': 'pane:show-next-item' 'g T': 'pane:show-previous-item' diff --git a/lib/panes.coffee b/lib/panes.coffee index 10d90116..923b8b35 100644 --- a/lib/panes.coffee +++ b/lib/panes.coffee @@ -34,5 +34,41 @@ class FocusPreviousPaneView extends FocusAction atom.workspace.activatePreviousPane() @focusCursor() +class MovePane + isComplete: -> true + isRecordable: -> false + constructor: (@orientation, @pos) -> + + execute: -> + rootContainer = atom.workspace.paneContainer + activePane = atom.workspace.getActivePane() + # nothing to do if there's only one pane + return if activePane.parent is rootContainer + + # hack: PaneAxis is not in Atom API + PaneAxis = activePane.parent.constructor + + activePane.parent.removeChild activePane + + rootPane = rootContainer.root + if rootPane.orientation isnt @orientation + newPane = new PaneAxis + container: rootContainer + orientation: @orientation + children: [rootPane] + rootContainer.replaceChild(rootPane, newPane) + rootPane = newPane + + rootPane.addChild activePane, switch @pos + when 'begin' then 0 + when 'end' then null + + activePane.activate() + activePane.getActiveItem()?.scrollToCursorPosition() + + + module.exports = { FocusPaneViewOnLeft, FocusPaneViewOnRight, - FocusPaneViewAbove, FocusPaneViewBelow, FocusPreviousPaneView } + FocusPaneViewAbove, FocusPaneViewBelow, + FocusPreviousPaneView, + MovePane } diff --git a/lib/vim-state.coffee b/lib/vim-state.coffee index 66462daf..ae8f84b2 100644 --- a/lib/vim-state.coffee +++ b/lib/vim-state.coffee @@ -142,6 +142,10 @@ class VimState 'focus-pane-view-above': => new Panes.FocusPaneViewAbove() 'focus-pane-view-below': => new Panes.FocusPaneViewBelow() 'focus-previous-pane-view': => new Panes.FocusPreviousPaneView() + 'move-pane-view-to-far-left': => new Panes.MovePane('horizontal', 'begin') + 'move-pane-view-to-far-right': => new Panes.MovePane('horizontal', 'end') + 'move-pane-view-to-very-top': => new Panes.MovePane('vertical', 'begin') + 'move-pane-view-to-very-bottom': => new Panes.MovePane('vertical', 'end') 'move-to-mark': (e) => new Motions.MoveToMark(@editor, @) 'move-to-mark-literal': (e) => new Motions.MoveToMark(@editor, @, false) 'mark': (e) => new Operators.Mark(@editor, @)