5

Is there a way to open a file from Neotree in a new split window?

I want to achive same functionality as Vim NERDTree shortcuts "i" and "s"

Or is that the wrong approach?

10

New recommendation (Jan 2017)

neotree comes with default bindings of | for vertical split and - for horizontal split.

The functions neotree-enter-horizontal-split and neotree-enter-vertical-split mentioned in my older recommendation below do not exist any more!


Old recommendation (May 2015)

Currently the i and I keys are not bound in neotree-mode-map.

So you can use the below after (require 'neotree),

(define-key neotree-mode-map (kbd "i") #'neotree-enter-horizontal-split)
(define-key neotree-mode-map (kbd "I") #'neotree-enter-vertical-split)

Then, when the cursor is on a file name, pressing i will open that file in a new window after horizontal split.

  • Does this depend on evil mode or spacemacs? I don't have either, and I tried the above answer and it produces Debugger entered--Lisp error: (wrong-type-argument commandp neotree-enter-horizontal-split) call-interactively(neotree-enter-horizontal-split nil nil) command-execute(neotree-enter-horizontal-split) – mark Jan 16 '17 at 0:03
  • @mark Please have a look at the update answer. Thanks for bringing this to my notice. – Kaushal Modi Jan 16 '17 at 18:13
  • @KaushalModi Thanks. Ah, my issue was complicated by the fact that el-get was installing an outdated version of neotree (described here github.com/jaypei/emacs-neotree/issues/219 ). Now that I'm using the latest version of neotree, - and | are working as expected – mark Jan 16 '17 at 20:05
2

In case of evil mode, you can do like this

(add-hook 'neotree-mode-hook
      (lambda ()
        (define-key evil-normal-state-local-map (kbd "TAB") 'neotree-enter-vertical-split)
        (define-key evil-normal-state-local-map (kbd "SPC") 'neotree-enter-horizontal-split)
        (define-key evil-normal-state-local-map (kbd "q") 'neotree-hide)
        (define-key evil-normal-state-local-map (kbd "RET") 'neotree-enter)))
  • I need this to actually use neotree – CESCO Mar 19 '17 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.