Hacker News new | ask | show | jobs
by cmrdporcupine 1035 days ago
I keep trying stripped down terminal editors as alternatives to emacs -- because these days I use like 1% of emacs anyways -- but I always severely miss the common emacs major modes for C/C++ etc and especially its approach to indentation there (tab to force correct indent). I really wish other editors would follow this convention.
1 comments

> I really wish other editors would follow this convention.

In editors with configurable keyboard shortcuts, you can bind this to tab yourself. For example, in Vim, the normal-mode command `==` would correctly reindent the current line. (Here, `=` is an operator, so you can also apply it to other regions like `=i{` to reindent correctly everything inside braces.)

To bind tab to reindent correctly in normal and visual mode, you can put this in your vimrc:

    nnoremap <tab> ==
    vnoremap <tab> =
You can also remap it in insert mode if you want, but then you might want to throw some if-statements in there to determine when to indent and when to reindent :)