Live data from Hacker News

Vim Splits – Move Faster and More Naturally

robots.thoughtbot.com

41–50 of 68 posts

Re: Vim Splits – Move Faster and More Naturally

#41
post #9
post #6

After years of abusing my little finger for using Ctrl & the RSI that goes with it, I tend to use alt/meta with my thumb more and more nowadays, for this I make it usable in insert mode also, this is probably one of the oldest bits of my .vimrc "quick window movements map map l map k map j map h imap li imap ki imap ji imap hi

Only problem with those imaps is that now you can't type ì, ë, ê, or è. Vim is pretty dumb about utf-8. I'd also suggest using instead of the ...i dance. Edit: "The way [Vim] stores alt+letter in its input queue collides with UTF-8/Unicode handling" -- LeoNerd in freenode/#vim at 2013-04-15 15:22:29

I code on a Macbook, and I actually use say... Option+i, e in order to get ê. That works inside Vim, too, I just found out.

Obviously not very helpful to people not on a Mac, but I don't have to go through Alt mappings at all.

Re: Vim Splits – Move Faster and More Naturally

#42

Mastering window splitting and tabbing allows one to truly step into the flow that Vim has to offer. However, it doesn't stop at simply dealing with opening files in new panes. :vsplit . I use this all the time when I need to find a file or I'm not sure where something is. It just opens the file browser in a new window split. It's extremely handy. Once you've got it open, it's important to note that you can use your…

    :vsplit .
On this point, it's worth noting that users of the NERDTree plugin[1] can set it to work with the above style of use as well:

    " Replace netrw with secondary NERDTree
    let NERDTreeHijackNetrw=1
[1] https://github.com/scrooloose/nerdtree/

Re: Vim Splits – Move Faster and More Naturally

#43

Mastering window splitting and tabbing allows one to truly step into the flow that Vim has to offer. However, it doesn't stop at simply dealing with opening files in new panes. :vsplit . I use this all the time when I need to find a file or I'm not sure where something is. It just opens the file browser in a new window split. It's extremely handy. Once you've got it open, it's important to note that you can use your…

Note that you can abbreviate :vsplit as just :vsp .

Re: Vim Splits – Move Faster and More Naturally

#44

Mastering window splitting and tabbing allows one to truly step into the flow that Vim has to offer. However, it doesn't stop at simply dealing with opening files in new panes. :vsplit . I use this all the time when I need to find a file or I'm not sure where something is. It just opens the file browser in a new window split. It's extremely handy. Once you've got it open, it's important to note that you can use your…

It's worth noting that :vsplit can and should be shortened to :vs

Also, depending on how you like to work, keeping a stable working directory can be very useful:

    :vs **/bar
is somehow less mentally taxing than:

    :vs ../../models/bar.php

Re: Vim Splits – Move Faster and More Naturally

#45

Mastering window splitting and tabbing allows one to truly step into the flow that Vim has to offer. However, it doesn't stop at simply dealing with opening files in new panes. :vsplit . I use this all the time when I need to find a file or I'm not sure where something is. It just opens the file browser in a new window split. It's extremely handy. Once you've got it open, it's important to note that you can use your…

Note that you can abbreviate :vsplit as just :vsp .

You can even drop the p (and spaces if you are using arguments) So to open a vertical split containing a file browser in the current dir:

    :vs.
I use this all the time.

Re: Vim Splits – Move Faster and More Naturally

#47

Mastering window splitting and tabbing allows one to truly step into the flow that Vim has to offer. However, it doesn't stop at simply dealing with opening files in new panes. :vsplit . I use this all the time when I need to find a file or I'm not sure where something is. It just opens the file browser in a new window split. It's extremely handy. Once you've got it open, it's important to note that you can use your…

Isn't there some way of using % to open a file relative to the current one perhaps? To get the best of both worlds.

I use:

    map e :e =expand("%:p:h") . "/" 
you can make one that splits:

    map v :vs =expand("%:p:h") . "/" 

Re: Vim Splits – Move Faster and More Naturally

#48
post #39

Earlier quoted context omitted.

Isn't there some way of using % to open a file relative to the current one perhaps? To get the best of both worlds.

I'm using the following to expand "%%" in command mode to the full path of the current open file's directory: cabbr %% expand('%:p:h') You could also use :. instead of :p to get the relative path, see :help c_% and :help filename_modifiers

Wow, elegant. Thank you!

Re: Vim Splits – Move Faster and More Naturally

#49

Mastering window splitting and tabbing allows one to truly step into the flow that Vim has to offer. However, it doesn't stop at simply dealing with opening files in new panes. :vsplit . I use this all the time when I need to find a file or I'm not sure where something is. It just opens the file browser in a new window split. It's extremely handy. Once you've got it open, it's important to note that you can use your…

It's worth noting that :vsplit can and should be shortened to :vs Also, depending on how you like to work, keeping a stable working directory can be very useful: :vs **/bar is somehow less mentally taxing than: :vs ../../models/bar.php

Can you point me to docs on in file searching? Those symbols are predictably hard to google. Based on a little messing around, it appears that * is what I expect from bash, and can also include directory separators.

Re: Vim Splits – Move Faster and More Naturally

#50
My happiest thing lately is to use NERDtree and then on selecting a bookmark, folder or file to then hit t to open that in a new tab.

So I have tabs and those are then split. Each subject of work or exploration has a tab with a few splits. I end up with much less clutter than sublime text. Easy to close out a tab.

Also ctrl-w v is my favorite way to split.

Post reply on HN