Live data from Hacker News

Vim Splits – Move Faster and More Naturally

robots.thoughtbot.com

31–40 of 68 posts

Re: Vim Splits – Move Faster and More Naturally

#31

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…

My .vimrc used to have:

    nnoremap - :Sexplore
Which opens netrw when you hit the - key. I now have it mapped to ctrlp instead (ctrl+enter in ctrlp to split open).

Re: Vim Splits – Move Faster and More Naturally

#32

Earlier quoted context omitted.

+1 For evil-mode. I'm still using MacVim and Emacs+Evil side by side because many things that my vim does (via plugins etc) my emacs/evil doesn't do yet and I lack the time to research it all. But having elisp for extension is such a joy to use. I've dabbled a bit with evil, too, and I really like how easy it is to extend it.

Funny, I just started using evil too. You might want to checkout prelude/projectile if you haven't yet. Also, less obviously for a vimmer, keychord.el. I'm able to use 'jk' for ESC, for instance. For others interested, the brief evil manual is worth peeking at: https://gitorious.org/evil/evil/blobs/raw/doc/doc/evil.pdf . Motions, text objects, and operators in theory are easy to add in elisp, which is cool. For this…

Yes, I feel similar. I've tried way too many vim 'emulators', and the only other one which comes close to that 'vim' feeling is XVim for XCode. However, neither that one, nor all the others feel as easily extendable (with the exception of Vico, a native Mac vim clone that uses Nu (a cocoa lisp) for extension, but Vico even though it's easily extendable lacks a ton of vim commands)

Re: Vim Splits – Move Faster and More Naturally

#33

I have mapped the Tab key to move between split windows. I also mapped Ctrl+T to open a new tab, and CTRL-H and CTRL-L to move to the left/right tab respectively. It works well and seem pretty natural. I suppose if I had a giant monitor I could use more splits, but realistically more than two of them feels very cramped. My .vimrc is here: https://raw.github.com/ipartola/ipartola-bash-and-vim/master... The relevant pa…

Splits came to vim way before tabs did as a result I use splits as vertical pseudo tabs:

    nnoremap  j_
    nnoremap  k_
Which does both split navigation and split maximizing. I could probably switch to tabs but I'm happy with how things work and I don't really see any advantage over how I'm doing things now.

Re: Vim Splits – Move Faster and More Naturally

#34
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

[deleted]

Re: Vim Splits – Move Faster and More Naturally

#35
post #11

I am SO SATISFIED with my splits key remapping I have to share it: map l map h map j map k map :split j " Horizontal split map :vsplit l " Vertical split map :close map K " Convert vertical to horizontal split map > L " Convert horizontal to vertical split

I have somewhat similar, though I map the hjkl keys to just the arrow keys themselves with no modifiers. The only problem is when other people are poking around at one of my vim sessions it trips them up.

Re: Vim Splits – Move Faster and More Naturally

#37

Also, I use dwm for tiled windows: http://www.vim.org/scripts/script.php?script_id=4186

Awesome (another tiling WM), tmux with panes, and vim with windows gives me three layers of organization. Really great if you are into self-imposed structure.

Re: Vim Splits – Move Faster and More Naturally

#38

I used to use splits, then I used tabs + splits, now I just use buffers. The only time splits come into it are for quickfix or diffs. Just get used to buffers. Lots of vim commands will work with buffers but not with splits or tabs. People new to vim will immediately jump on splits or tabs because of how their previous editor work flow worked, but you aren't going to unlock the full power of vim until you get used to…

I use buffers and splits.

My work session has about a hundred or two "open" files in the buffer, and I split and un-split windows often so that I can view multiple files at once.

But my most common way to change current file is :b

I occasionally prune my buffers for files that have been deleted, but it's mostly unnecessary to. When I close it, I just save the session in a file and re-open the session.

Re: Vim Splits – Move Faster and More Naturally

#39

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'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

Re: Vim Splits – Move Faster and More Naturally

#40

I used to use splits, then I used tabs + splits, now I just use buffers. The only time splits come into it are for quickfix or diffs. Just get used to buffers. Lots of vim commands will work with buffers but not with splits or tabs. People new to vim will immediately jump on splits or tabs because of how their previous editor work flow worked, but you aren't going to unlock the full power of vim until you get used to…

I agree with regard to tabs, but I always felt like buffers were orthogonal to splits. I use both all of the time. Buffers to manage a working set of files and splits to manage the files that I want to viewable. I frequently find myself using splits to write new code while referencing other parts of the code base (or even the same file).

Same here, I can quickly have all the functions, data, and docs visible, that I need for the particular code that I'm currently writing. Having to switch back and forth would only confuse me. Usually, the biggest problem I have with other IDEs is that they don't allow me to split as freely as vim / emacs do. XCode is shockingly stupid about it, for example.
Post reply on HN