adding support for splitright and splitbelow

This commit is contained in:
Xiaolong Wang 2016-03-18 14:09:14 -05:00
parent 145446b8de
commit fdd8b36e62
2 changed files with 43 additions and 12 deletions

View file

@ -35,3 +35,15 @@ module.exports = ExMode =
consumeVim: (vim) -> consumeVim: (vim) ->
@vim = vim @vim = vim
@globalExState.setVim(vim) @globalExState.setVim(vim)
config:
splitbelow:
title: 'Split below'
description: 'when splitting, split from below'
type: 'boolean'
default: 'false'
splitright:
title: 'Split right'
description: 'when splitting, split from right'
type: 'boolean'
default: 'false'

View file

@ -258,6 +258,15 @@ class Ex
filePaths = args.split(' ') filePaths = args.split(' ')
filePaths = undefined if filePaths.length is 1 and filePaths[0] is '' filePaths = undefined if filePaths.length is 1 and filePaths[0] is ''
pane = atom.workspace.getActivePane() pane = atom.workspace.getActivePane()
if atom.config.get('ex-mode.splitbelow')
if filePaths? and filePaths.length > 0
newPane = pane.splitDown()
for file in filePaths
do ->
atom.workspace.openURIInPane file, newPane
else
pane.splitDown(copyActiveItem: true)
else
if filePaths? and filePaths.length > 0 if filePaths? and filePaths.length > 0
newPane = pane.splitUp() newPane = pane.splitUp()
for file in filePaths for file in filePaths
@ -266,6 +275,7 @@ class Ex
else else
pane.splitUp(copyActiveItem: true) pane.splitUp(copyActiveItem: true)
sp: (args) => @split(args) sp: (args) => @split(args)
substitute: ({ range, args, editor, vimState }) -> substitute: ({ range, args, editor, vimState }) ->
@ -335,6 +345,15 @@ class Ex
filePaths = args.split(' ') filePaths = args.split(' ')
filePaths = undefined if filePaths.length is 1 and filePaths[0] is '' filePaths = undefined if filePaths.length is 1 and filePaths[0] is ''
pane = atom.workspace.getActivePane() pane = atom.workspace.getActivePane()
if atom.config.get('ex-mode.splitright')
if filePaths? and filePaths.length > 0
newPane = pane.splitRight()
for file in filePaths
do ->
atom.workspace.openURIInPane file, newPane
else
pane.splitRight(copyActiveItem: true)
else
if filePaths? and filePaths.length > 0 if filePaths? and filePaths.length > 0
newPane = pane.splitLeft() newPane = pane.splitLeft()
for file in filePaths for file in filePaths