views:

421

answers:

2

I have the following in my .Zshrc

. /Users/Masi/bin/Zsh/prompt

I need run the following code to access the file from .zshrc

    Ctrl-Z 
    vim ~/bin/Zsh/prompt

I tried to do the same unsuccessfully by first highlighting the path in visual mode and running

:'<,'>!vim

How can you move fast between files in Vim?

+4  A: 

If you have vim open, you can open a file for editing using the :e <filepath> command.

If you want to have multiple files open simultaneously in the same vim session, you can use windows. You can open a new window with Ctrl-W n, then use :e <filepath> to open the file in the new window. It's probably better for you to find a tutorial for how to use windows than for me to do a poor job explaining how here. They're not too difficult to use though.

Another alternative is to have a separate vim session for each file, then to cycle through them as needed using job processing. I'm not familiar with the zsh syntax, but in bash, you can press Ctrl-Z to pause the currently running job and return to the command line, and resume a job with fg %n where n is the job number you want to resume. So you can use these to open file 1 with vim, pause vim, open up file 2 with a new vim session, pause it, and alternate back and forth with pausing and foregrounding as necessary.

Hope this helps!

Swiss
Instead of Ctrl-W n, i find :vsplit and :split easier to remember.
sharth
I know remember the reason why I did not use the Window button. I have the following bug in my Screen: http://stackoverflow.com/questions/809935/unable-to-solve-a-bug-in-vims-tlist-with-screen/809975#809975 My Vim gets upset when I have vertical split.
Masi
*know should be now
Masi
+3  A: 

I think you might be looking for the gf command in Vim, which opens the file that is named at the cursor position. This command opens the file in the same window, replacing whatever file you were previously editing. If you want to open a new window with the file under the cursor, use ^Wf.

See also the question How do you return from 'gf' in Vim for more information on file navigation.

Greg Hewgill
I get the following error message when I try to use gf: Not an editor command: OpenLocationTab <cfile>. Your other command then again works.
Masi