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

More keystrokes when navigating the code

(I know, if vim was second nature to me, this point would probably be moot... but I'm still using the arrow keys a lot :) )




In vim, you can have the tab key print 4 (or n) space characters, have movement keys jump over the 4 spaces like they would with tab characters, and delete the 4 spaces with one keystroke the same way. I don't remember the settings right now but I'll add them to this post when I get home.


please do... when I looked it, I was only able to find how to insert n spaces, and delete n spaces with a single keypress, but I sorely missed the ability to have the arrow keys jump :)


Actually, I'm not sure if I figured out how to make the movement keys treat spaces as tabs, I guess I normally end up using 0/b/$/^ if I need to navigate around them (sorry!). These settings are what I use, and will at least change backspace to delete 4 spaces in one keystroke instead of 4, which is what always annoyed me most.

    set tabstop=4
    set shiftwidth=4
    set softtabstop=4
    set expandtab


The point is also moot in Emacs. What editor are you using that forces you to navigate one space at a time rather than being able to at least jump around by word?


I use vim. When indenting with tabs, I can use "x" (delete one character) to remove a level of indentation. When indenting with spaces, I can't. The dedent command is more verbose than just hitting "x". If I forget when working in a file with spaces, then I have a three space indent. That off-by-one-character is harder to see and correct than a giant missing tab.

Why have one of the most common semantic units in source code (indentation) represented by four characters when there is an otherwise unused character that has already great editor support. Tabs work well in every editor I've used (except notepad.exe, which can't change their display width). Spaces only work well in smart editors.


In vim, ">>" and "<<" will indent and dedent the current line. It doesn't work with spaces and tabs mixed in with the line though. Bonus is you can do things like "10<<". This works even better with ":set rnu" turned on.


Rebind dedent to a little-used key, perhaps? I don't dedent so often that hammering a key twice is a big deal, though.

Editors aren't the only place code appears. I see it in my terminal, in git, in various web-based tools, in email, in browser textareas, etc. I don't want to reconfigure all of these things to make your code look like you see it (if they're even possible to reconfigure), also potentially breaking other applications that take for granted that a tab character aligns to 8.


I see. I'm unaffected by this problem in my editor. Also, I am able to (and do) use a mouse most of the time.

Thanks for clarifying!




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: