Hacker News new | past | comments | ask | show | jobs | submit login
Vim Splits: A Guide to Doing Exactly What You Want (technotales.wordpress.com)
47 points by s3b on May 17, 2010 | hide | past | favorite | 11 comments



I've recently invested some time in learning to use vi proficiently, beyond the basic hjkl movement and i/Esc

I've installed the Vrapper plug-in for eclipse as well... but since I find eclipse to be full of features but bloated as hell I've done some research on how to use Vi/m as an IDE.

I recommend to everyone eager to learn Vim, this free book

A byte of Vim - http://www.swaroopch.com/notes/Vim

There are a number of Vim scripts to ease developing, and thus making Vim become more of an IDE. For example:

Vim trinity http://www.vim.org/scripts/script.php?script_id=2347

includes the useful NERD_tree, taglist and srcexpl

NERD_commenter http://www.vim.org/scripts/script.php?script_id=1218

mru.vim http://www.vim.org/scripts/script.php?script_id=521

xml.vim http://www.vim.org/scripts/script.php?script_id=1397

There are many more plugins, and a lot of language-dependent plugins to help you develop in your language of choice, be it java, ruby, python, C, etc

I guess a great part of HN users are already masters of Vi/m, but I thougt this could be helpful for those still in their path to Virvana


    map <C-j> <C-W>j<C-w>_
    map <C-k> <C-W>k<C-w>_
    map <C-h> <C-w>h<C-w>_
    map <C-l> <C-w>l<C-w>_
Try these. They expand the window they move into. You'll love them.


Nice - I can imagine a workflow where you keep two vertical panes open, the left one with the main file you're working with, the right one with a whole bunch of auxiliary files; then you can use these mappings to easily jump between the right-hand files, while keeping them all visibly accessible. Gonna try this!


I usually have never found vertical splits to be helpful, though others may disagree. I prefer to keep several horizontal splits (in your case above). Just use C-j or C-k, your current file is maximized.

Remember, you have other options too, such as tabs, and just opening aux files as buffers and C-n or C-p to get to them.


I personally like to use tinymode[1] for such things in order to reduce map pollution (if such a term exists).

[1] http://www.vim.org/scripts/script.php?script_id=2223


It's easier to "map <C-?> <C-w>?" for ? in [j,k,h,l] and do "autocmd WinEnter * resize" separately. Especially since it's easier to disable.


Wow! That's amazing. Turns vim into a kind of cardfile. I like this (compared to a buffer explorer) - the visual indication of where the file is is nice.


I usually just do

  map <Tab> ^W^W
I only have one split at a time (very rarely going up to three).


omg, most of us have TAB mapped to insert-completion -- i've now got it mapped to snipMate.vim plugin.

In any case, ^w^w is quite easy to press twice without mapping, although that's entirely your call. It's fine if you have 2 equal splits and only want to jump to the other without resizing. When you have > 3, you definitely want to maximize the current split.


C-x 2 for horizontal split, and C-x 3 for vertical ;-)


The big feature Emacs provides that Vim doesn't in this case is integration with the window manager. Emacs lets me create another X window that shares the same set of buffers, clipboards, and other state with another. This is advantageous because it works like everything else and is especially useful with a tiling window manager.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: