Live data from Hacker News

Why I can’t stop using Vim

kornerstoane.com

11–20 of 169 posts

Re: Why I can’t stop using Vim

#11
post #4

"/ for searching (really, no other editor has made it this simple)" Well, it's really esc-/ which is no easier than ctrl-f. Or am I missing something? Edit: Same with "1G to go to the top of the file, G to go to the bottom" - esc-1-shift-g vs ctrl-home. Same with ctrl-end.

No need to use 1G at all, gg does the same and is one key less.

Re: Why I can’t stop using Vim

#12
post #4

"/ for searching (really, no other editor has made it this simple)" Well, it's really esc-/ which is no easier than ctrl-f. Or am I missing something? Edit: Same with "1G to go to the top of the file, G to go to the bottom" - esc-1-shift-g vs ctrl-home. Same with ctrl-end.

It sounds like you're assuming that the default is insert mode. If you're in insert mode the majority of the time you're not really using vim correctly.

Re: Why I can’t stop using Vim

#13
post #4

"/ for searching (really, no other editor has made it this simple)" Well, it's really esc-/ which is no easier than ctrl-f. Or am I missing something? Edit: Same with "1G to go to the top of the file, G to go to the bottom" - esc-1-shift-g vs ctrl-home. Same with ctrl-end.

I disagree with this. You're not normally in insert mode when using vim, you're in normal mode (the one vim starts in).

This means that it really is / for searching, 1G to go to the top of the file, w to go one word forward, f( to go to the next opening paren, and ci" to change everything inside the current "..." etc.

What this also means is that when inserting text you start by pressing i, type the text you want to insert and then immediately press ESC (or CTRL+[) to go back to normal mode.

The reason is that everything that is not directly inserting text is much quicker and faster to do in normal mode compared to insert mode once you learn a few of the commands.

I probably only spend a few percent of my vim-time in insert mode, most of it is spent in normal mode.

Re: Why I can’t stop using Vim

#14
post #10
post #4

"/ for searching (really, no other editor has made it this simple)" Well, it's really esc-/ which is no easier than ctrl-f. Or am I missing something? Edit: Same with "1G to go to the top of the file, G to go to the bottom" - esc-1-shift-g vs ctrl-home. Same with ctrl-end.

Or am I missing something? Indeed you are. The / command in vim is a motion . This means it can be combined with any command that expects a motion as input. For one example of this, try typing " d/foo " (excluding quotes). This will delete all text from the cursor to the first occurrence of foo .

I'll have to remember that. Cheers.

Re: Why I can’t stop using Vim

#15

It's unfortunate that, to me, the title implies there's something wrong with a person who still uses vim and nothing could be further from the truth.

Oh c'mon. Us vim users are seen as "those crazy people" by the majority of other programmers, and they have at least some point :)

Re: Why I can’t stop using Vim

#16
post #4

"/ for searching (really, no other editor has made it this simple)" Well, it's really esc-/ which is no easier than ctrl-f. Or am I missing something? Edit: Same with "1G to go to the top of the file, G to go to the bottom" - esc-1-shift-g vs ctrl-home. Same with ctrl-end.

> Same with "1G to go to the top of the file, G to go to the bottom" - esc-1-shift-g vs ctrl-home. Same with ctrl-end.

gg beats both (I don't think I've ever used 1G to jump to the top of the file)

Re: Why I can’t stop using Vim

#17
post #4

"/ for searching (really, no other editor has made it this simple)" Well, it's really esc-/ which is no easier than ctrl-f. Or am I missing something? Edit: Same with "1G to go to the top of the file, G to go to the bottom" - esc-1-shift-g vs ctrl-home. Same with ctrl-end.

I think you're using the editor's modality wrong.

ESC is not used to exit from Insert mode. ESC is used to switch from any mode back to Command mode. In fact Command mode is also called Normal mode. You should spend 95% of your time in Normal mode and use the other modes when you need them.

I suggest binding `kj` to ESC since it allows you to quickly make a change and continue browsing your code. Take the following session:

* Browse and spot something that needs to be changed

* Type `ci(messages, callbackkj`

* Keep browsing with `hjkl` as you're in Normal mode

While it may seem weird, I've yet to find an occurrence of `kj` in a program in years of using this binding and my hands haven't left the keyboard. The cognitive weight is zero as well (at least after building muscle memory).

Now, I believe it depends on the kind of programmers you are. My coworker is the kind who types in a lot of code and rewrites a lot of stuff. I'm the kind of rewires things and make subtle changes after spending a lot of time reading it. In other words it works well for me but probably wouldn't for him.

Re: Why I can’t stop using Vim

#19
post #8
post #4

"/ for searching (really, no other editor has made it this simple)" Well, it's really esc-/ which is no easier than ctrl-f. Or am I missing something? Edit: Same with "1G to go to the top of the file, G to go to the bottom" - esc-1-shift-g vs ctrl-home. Same with ctrl-end.

I don't really agree about "esc". "Normal mode" is the normal mode as the name indicates. That's where you normally start from. It's the actual writing that's two characters more (start insert mode, write, exit). Unless you're just writing new file from scratch in one go, you're likely to be in normal mode a lot of the time. Also, shift is not needed for the beginning of the file. It's also "gg" for the first line /…

What's ^Home / ^End? If it's moving to the beginning / end of a line there are vi shortcuts for that: ^ and $.

Re: Why I can’t stop using Vim

#20
First you'll learn how to orientate around text quickly using normal mode, then you'll start playing with tabs, splits and buffers to search between multiple files, and then you'll start using registers to save phrases and regular expressions to search directories. At that point you'll never want to leave Vim again.

:wq

Post reply on HN