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.
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.
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<CR>" (excluding quotes). This will delete all text from the cursor to the first occurrence of foo.
Also, shift is not needed for the beginning of the file. It's also "gg" for the first line / "G" for the last.
Regarding the ctrl+home/end, I much prefer not using them. Simply because I switch between 4 different keyboards during the week and I don't know where home/end are without looking. (3 of them being laptops with wildly different layouts) gg/G are on the home row. That's much easier.
For instance, ci} will delete everything inside the tightest enclosing braces and switch you to insert mode. This whole thing, then, including what you type, is a single action that you can redo with .
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.
Interesting, I was thinking something similar - suitability for maintenance vs from scratch.
It took production down for 30 minutes until I noticed it. Remember, kids! ":set paste".
I just tried it, it doesn't work :( That's too bad.
Also, you can have this in your vimrc:
set clipboard=unnamedplus
And then your vim copy-paste will be in sync with system clipboard(no need for +p or +y).Or get used to ctrl-[ which is easier to type than Esc, doesn't skip events(like ctrl-c), and doesn't interfere with anything.
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.
gg beats both (I don't think I've ever used 1G to jump to the top of the file)
I didn't find the magical 'g' until much later, and 1G was already burned into my synapses. I'm trying to change. It's a little awkward :)
:10 :25 :1
I tend to use that a lot now and I don't know why. However, you can do some pretty cool command with ranges of lines.
On the other hand, it would probably be easier to rebind something like '-' as end-of-line. I'd do backspace, but I've already changed that to PageUp (backspace/space work great as PageUp/PageDown)
Esc requires you twist your entire left hand sideways up to hit the Esc, whereas Ctrl requires you move only your left pinky to hit the Ctrl.
Ctrl is more efficient.