(minor tweaks) |
|||
Line 1: | Line 1: | ||
+ | {{Duplicate|193|1322}} |
||
− | <div id="News" style="background-color: #ccffcc; margin: 0 1em 0 1em; padding: 0 10px; border: 1px solid #000;"> |
||
− | <big>'''Duplicate tip'''</big> |
||
− | |||
− | This tip is very similar to the following: |
||
− | *[[Insert current filename]] |
||
− | These tips need to be merged – see the [[Vim_Tips_Wiki:Merge_guidelines|merge guidelines]]. |
||
⚫ | |||
{{review}} |
{{review}} |
||
{{TipImported |
{{TipImported |
||
Line 11: | Line 5: | ||
|previous=529 |
|previous=529 |
||
|next=531 |
|next=531 |
||
− | |created= |
+ | |created=2003 |
|complexity=basic |
|complexity=basic |
||
|author=Geoff Hubbard |
|author=Geoff Hubbard |
||
|version=5.7 |
|version=5.7 |
||
|rating=15/19 |
|rating=15/19 |
||
− | |category1= |
+ | |category1=Duplicate |
|category2= |
|category2= |
||
}} |
}} |
||
To get the name of the file you are currently editing use: |
To get the name of the file you are currently editing use: |
||
+ | <pre> |
||
− | |||
− | + | @% |
|
⚫ | |||
If you want to make sure of the path as well use: |
If you want to make sure of the path as well use: |
||
+ | <pre> |
||
− | |||
− | + | expand("%:p") |
|
+ | </pre> |
||
==References== |
==References== |
||
Line 53: | Line 49: | ||
Complete path, filename and extension: |
Complete path, filename and extension: |
||
2+Ctrl-G |
2+Ctrl-G |
||
− | [[Category:Duplicate]] |
Revision as of 03:34, 27 March 2011
Duplicate tip
This tip is very similar to the following:
These tips need to be merged – see the merge guidelines.
Tip 530 Printable Monobook Previous Next
created 2003 · complexity basic · author Geoff Hubbard · version 5.7
To get the name of the file you are currently editing use:
@%
If you want to make sure of the path as well use:
expand("%:p")
References
- :help @
- :help expand()
- :help cmdline-special
- Copy filename to clipboard shows why it might be useful
Comments
To enter the name of the current file in insert or command mode, use <C-R>%.
If you want to use it as part of a command line just use %, for example:
!echo %
Without the extention:
!echo %:r
Ctrl-G is an easier way to get this info.
If you need to insert otherfile names (say the *.h name in an #include), you can do C-X+C-F for filename completion.
Complete path, filename and extension:
2+Ctrl-G