Hacker News new | past | comments | ask | show | jobs | submit login

I didn't know this was possible:

    " Resize splits when the window is resized
    au VimResized * exe "normal! \<c-w>="
That's really handy. Also, this part made me smile:

    " Heresy
    inoremap <c-a> <esc>I
    inoremap <c-e> <esc>A



(I love both editors)

That's something disgusting about Vim - mapping to other keys instead of commands. In Emacs its much nicer IMO:

    (global-set-key (kbd "C-a") 'beginning-of-line)


Disgusting but practical. I already know the keys on the right because I use them every day. If it were a function I'd have to look it up first.


Is there a Vim equivalent of Emacs's C-h k followed by the key combo, which basically says, "Tell me what the official command name is for this keystroke?"


I don't know of anything quite like that but the help can be searched by key, though only for the default key combinations, e.g. ":h i^a" would show the docs for the ctrl-a command in insert mode.

Note though that vim really doesn't have commands the same way as emacs does. That's why you generally see assigning one key combination to another instead of some "command name."


You can bind a key to a command too. However, mapping to keys allows you to create your own. To give you a crude example, you could map a key to go down 5 times (5j). A real example would be more complicated for some specific task -- jump to other window, maxmimize it, go down to 5th line or some bookmark, etc.


Mapping to keys lets one map to the first part of a key sequence as opposed to the whole sequence/command name.


"C-w =" equalizes the size of splits. That works fine if you already had them near-equal, but I frequently shrink or maximize split windows, and I don't want them equalizing every time the window resizes.


You could bind a key to :setlocal winfixwidth, and press that when you want a certain window to not be resized.

Or just not worry about it at all -- each person has their own way of working with Vim.


Having paired with many people who have loaded Emacs keybindings into Vim, this made me laugh.

But serious talk:

Unless someone has loaded Emacs keybindings, shouldn't <C-a> be used to increment a number (even a hexadecimal one)? How is that heresy? Not having <C-a> makes several macros difficult.


The comment is cute, but doesn't it make more sense to just map to End itself since A is essentially a shortcut for <End>a

  inoremap <C-e> <End>
Technical note: I's behavior changes depending on 'cpo' so you can't just map it to <C-o>^.


Huh, I never thought of that. I always use A to get to the end of the line, so I never touch the End key. Good idea.


You use $ too sometimes?




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

Search: