search

Home  >  Q&A  >  body text

macvim - How to create and delete files in Vim

vim is a very powerful editor, and when used with NERDTree, you can easily open files, search for files, etc. However, files cannot be created or deleted, which is somewhat inconvenient.

vim has a simple command line function and can perform touch/rm operations.
Is there a way that when NERDTreeC goes to a certain directory, the vim terminal can also automatically cd to the directory, so that when using the vim command line to create and delete files, it will not Need to write a long path

Thank you everyone for your answers, it made me realize that I asked such a SB question

PHP中文网PHP中文网2776 days ago1274

reply all(9)I'll reply

  • 阿神

    阿神2017-05-16 16:42:48

    -_-

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 16:42:48

    = =
    Sir, do you know that in command mode, add in front of! Can execute shell commands

    For example:! mkdir www to create a new folder.
    ! rm to delete the file

    Of course, if you use Windows, just pretend I didn’t say anything

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 16:42:48

    vim is a very powerful editor. When used with NERDTree, you can easily open files, search for files, etc. However, files cannot be created or deleted, which is somewhat inconvenient.
    1. Create a new file. Isn’t it equivalent to creating a new file by adding a file name suffix in vim and saving it? Or as someone above said:!touch, but this is a command to call the operating system. Linux has it, but I don’t know about windows. Deleting files is similar

    vim has a simple command line function and can perform touch/rm operations.
    Is there a way that when NERDTreeC goes to a certain directory, the vim terminal can also automatically cd to the directory, so that when using the vim command line to create and delete files, there is no need to write a long path
    2. Does NerdTree have this function? See the help information given above

    reply
    0
  • 某草草

    某草草2017-05-16 16:42:48

    Give you a simple cheatsheet

    https://gist.github.com/ldong/f05bbae89079f52cca0e

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-16 16:42:48

    C-x, C-f

    reply
    0
  • 某草草

    某草草2017-05-16 16:42:48

    Incorrect, m reported an error
    And the NERDTree created with the command is not updated in real time

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-16 16:42:48

    https://github.com/tpope/vim-eunuch

    • :Remove: Delete a buffer and the file on disk simultaneously.
    • :Unlink: Like :Remove, but keeps the now empty buffer.
    • :Move: Rename a buffer and the file on disk simultaneously.
    • :Rename: Like :Move, but relative to the current file's containing directory.
    • :Chmod: Change the permissions of the current file.
    • :Mkdir: Create a directory, defaulting to the parent of the current file.
    • :Find: Run find and load the results into the quickfix list.
    • :Locate: Run locate and load the results into the quickfix list.
    • :Wall: Write every open window. Handy for kicking off tools like guard.
    • :SudoWrite: Write a privileged file with sudo.
    • :SudoEdit: Edit a privileged file with sudo.

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-16 16:42:48

    Windows users can tell you that it can also be used in gvim! Add cmd command to operate the file, but the cmd window will pop up during the command execution...

    By the way, after using commands to operate files, NERDTree cannot automatically refresh the directory...

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 16:42:48

    Newcomers would like to add: NERDTree cannot automatically refresh the directory...you can use shift+R to refresh manually.
    Also, just read the answer given on the 1st floor carefully. After the cursor points to the file, press m and four file operations will appear. At this time, you can create, delete, copy and other operations.

    reply
    0
  • Cancelreply