In Ivy, when I try to create a new file directly in a new folder (meaning, as I type C-x C-f, and then write a file path, say /current_path/new_folder/new_file), the new_file along with the new_folder is not created. Is there a better way to do this ? What suitable key binding do you suggest along with an elisp code for this solution ?

  • 1
    Sorry, your question is not very clear. Can you please list in further detail the steps you would like to take, and what you would like to happen at each step? Have you tried setting the user option ivy-magic-slash-non-match-action to 'ivy-magic-slash-non-match-create?
    – Basil
    Jun 19 '18 at 5:42
  • It is also prompt the nonexistent file path.
    – cc d
    Jun 19 '18 at 6:09
  • The error report: Debugger entered--Lisp error: (error ":working-directory /Users/sb/Github/believingdying/react-app/src/components/yes/ of syntax checker javascript-jshint does not exist") signal(error (":working-directory /Users/sb/Github/believingdying/react-app/src/components/yes/ of syntax checker javascript-jshint does not exist")) error(":working-directory %s of syntax checker %S does not exist" "/Users/sb/Github/believingdying/react-app/src/components/yes/" javascript-jshint) flycheck-compute-working-directory(javascript-jshint)
    – cc d
    Jun 19 '18 at 6:16
  • 1
    Please update your question with error details, instead of posting them in comments. Please also list in detail which keys/commands cause the error. In brief, please try to make the recipe as reproducible as possible. Does the error still occur if you enable ivy-mode after emacs -Q?
    – Basil
    Jun 19 '18 at 6:25

In ivy, it can not to create directly a new file in a new folder

Emacs can do this regardless of whether ivy-mode is enabled, or whether you are using counsel-find-file. You will be prompted to create any non-existent parent directories when you try to write the buffer contents to a file (e.g. C-xC-s), or you can create them yourself via M-xmake-directoryRETRET.

See also the following blog post for how to configure Emacs to automatically create non-existent parent directories: http://iqbalansari.me/blog/2014/12/07/automatically-create-parent-directories-on-visiting-a-new-file-in-emacs/

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.