Vim nerdtree rename file




















The NERDTree plugin is not only useful as a file system explorer, you can use it to manipulate files, too. In Vim, you can execute commands in your shell without opening a new terminal with :! To rename a file, you'll want to execute mv :. The caveat with this approach that if you rename the file in the current buffer, it won't be available anymore and Vim will give you an error. You'll have to reload it from its new location to keep working on it.

Which approach do you prefer? We need to change each line to be a valid stand-alone shell command. See VimTip for more details. You can use any Vim features here macros are useful , as long as each line results in a valid shell command. The reason this works is Vim writes a file line-by-line. So if you started with a list of file names, it will execute mv commands. Sure there are utilities that may do this better, but Vim is always available and that's one less thing you have to remember.

This will pipe the whole buffer to the system command bash , thus executing all of the move commands. This will also replace the file with the command's output, which is useful for commands besides mv. You can also visually select a small subset of lines, and only execute those commands:. When we are navigating through the nerdtree window, we may want to copy the full path or the relative path of current node. First, we need to create a file, e.

Anyway, create file mymapping. Similarly, to yank the relative path relative to current root of current code using yr , we can use the following settings:. For the meaning of fnamemodify , see here. Ok, that is all the settings. Nerdtree shows all the files and directories under current root by default. If you want to ignore certain files and folder, e. Use the following setting in your Nvim config:. I got my inspiration from here , here and also the nerdtree documentation.

LastMod GetSelected if n!



0コメント

  • 1000 / 1000