Monday, December 28, 2009

Vim tip - open file under cursor














In order to open a file whose 'name' (path) is under the cursor


gf : open in the same window ("goto file")
Ctrl-w f : open in a new window
Ctrl-w gf : open in a new tab

And to return to the previous file or buffer : Ctrl-o

To learn more about vi 'gf' command , here is a good resource

Related posts:
- Pull word under cursor - vi editor tip
- Using tabs in vim editor - a short tutorial

2 comments:

Adithya Kiran said...

Hey jadu, why can't you open space for us to post some new tips which are not listed by you? Every time i am writing new tips under comments section which are irrelevant to the post. However, i want to share a new tip.

Tip:
By default, vim doesn't let the cursor stray beyond the defined text. This setting allows the cursor to freely roam anywhere it likes in command mode. It feels weird at first but is quite useful.

All you have to do is,

:set virtualedit=all

happy vimming..!

Unknown said...

@Adithya, thank you so much. its a great vim tip. I need a suggestion from you : How can I have the open space so that my readers can post questions/tips/new posts ? will be a great help. Thanks in advance.

© Jadu Saikia www.UNIXCL.com