How do I create a directory from within Emacs?

前端 未结 6 2062
夕颜
夕颜 2021-01-29 20:15

How exactly can I create a new directory using Emacs? What commands do I use? (If possible, please provide an example)

6条回答
  •  再見小時候
    2021-01-29 20:58

    • to create the directory dir/to/create, type:

      M-x make-directory RET dir/to/create RET
      
    • to create directories dir/parent1/node and dir/parent2/node, type:

      M-! mkdir -p dir/parent{1,2}/node RET
      

      It assumes that Emacs's inferior shell is bash/zsh or other compatible shell.

    • or in a Dired mode

      +
      

      It doesn't create nonexistent parent directories.

      Example:

      C-x d *.py RET ; shows python source files in the CWD in `Dired` mode
      + test RET     ; create `test` directory in the CWD
      

      CWD stands for Current Working Directory.

    • or just create a new file with non-existing parent directories using C-x C-f and type:

      M-x make-directory RET RET
      

    Emacs asks to create the parent directories automatically while saving a new file in recent Emacs versions. For older version, see How to make Emacs create intermediate dirs - when saving a file?

提交回复
热议问题