Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use Ctrl-G to see the path. But I want to enter the path to the file itself.

How can I achieve this in Vim?

share|improve this question
up vote 6 down vote accepted

The name of the current file is contained in the % register. See

:help quote%

You can insert the contents of that register as you would any other register, e.g.,

"%p
"%P
:put %

and in insert mode as

<C-R>%

where <C-R> means Ctrl-R.

You can also expand the file name to its full path and select various parts of the path or file name using expand() and file name modifiers. See

:help expand()
:help filename-modifiers

As an example, while in insert mode, you could type

<C-R>=expand("%:p")

followed by Enter, where again <C-R> means Ctrl-R, which would insert the full path name of the current file. See

:help i_CTRL-R_=
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .