37

Currently, I know that I can create a new file with the following ways:

  • c key in Neotree
  • SPC ' in shell layer, and use the touch xxx command

I am wondering whether there is a simple way (something like SPC f xxx) or not.

Thanks.

user2331095
  • 6,577
  • 8
  • 36
  • 56

2 Answers2

57

Yes, you can use SPC f f, enter the name of the new file and then select the line starting with [?] (which is the default if no other file matches).

Note you can also use this to create files in non-existing subfolders, like SPC f f my/sub/folder/file.txt RET.

StreakyCobra
  • 1,991
  • 23
  • 17
  • 11
    autocompletion is evil in this case, it tries to open file that somehow matches your new name – fl00r Oct 26 '16 at 14:23
  • 1
    If you're using ivy, `C-M-j` (ivy-immediate-done) selects the current input instead of a match http://oremacs.com/swiper/. Helm probably has a similar feature. – mk12 Nov 29 '17 at 03:20
  • I am using emacs binding and want to create new file inside directory open in neotree buffer using C-c C-n – Neeraj Verma Apr 16 '18 at 08:44
  • For helm `M-SPC j` will enter transient state and go down one to the line starting with `[?]`. You can also use the down arrow. I find none of these ideal. – young_souvlaki Jan 07 '22 at 21:41
5

If you are using the standard vim like keybindings,

:e /path/to/file

works opens a file ( which doesn't have to exist before )

:x

saves the file and closes the buffer and

:w

saves without closing.

xophos
  • 366
  • 4
  • 19