Search code examples
vimnetrw

How to get a file path or a file name in netrw of Vim


I would like to get a file path or a file name in netrw easily.

Is there any way to get a file path or a file name in netrw of Vim?


Solution

  • You can select the file name under cursor in netrw, copy it to the buffer with y and enter the following command: :echo @%."/".@".

    Explanation: @{0-9a-z".=*+} executes the contents of the register {0-9a-z".=*+}. The % register is a name of the current file. For netrw, this is the name of the open directory. The " register contains the copied file name. The . operator means concatenation of the strings in the vimscript.