VIM Split screens!

Posted on Updated on

I found out this trick a year and a half too late but here’s how to open, view and edit 2 or more source codes from different directories in the same window using VIM on a mac.

1) esc + :
2) type “vsp” + filepath/filename
e.g. my other C++ source file is in the directory above the one I’m in now, so in my terminal after step 1, I would type ../FirstSolution.cpp then hit enter

vsp means vertical split screen. If you want, type sp for horizontal split screen.

Easy! Although I much prefer sublime text in general, but I know there are some VIM fans out there:)

Advertisements

4 thoughts on “VIM Split screens!

    fulcronz27 said:
    28/04/2015 at 8:14 am

    I also like this trick very much. I use it everyday but differently.
    I do it by Ctrl + w + s/v.
    It’s good to know the actual command from yours. : )

      Benji responded:
      28/04/2015 at 8:20 am

      Hi! I tried to use your method but I’m not sure why I can’t do the same even by hitting esc + :
      Do you just open the file and just hit those commands or do you do something else before?

        fulcronz27 said:
        28/04/2015 at 8:23 am

        In navigate mode (the one you reach by keep pressing esc esc esc)
        Do it in 2 steps, each step press keys at the same time
        1. Ctrl + w
        2. v
        Should work

    Benji responded:
    28/04/2015 at 8:33 am

    Cool thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s