6 ms·
"/ 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:
by disputin 12y ago
"/ 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.
- deleted 12y ago[deleted]
- viraptor 12y agoI 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 / "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.
- nakkiel 12y agoWhat's ^Home / ^End? If it's moving to the beginning / end of a line there are vi shortcuts for that: ^ and $.
- disputin 12y ago"It's the actual writing that's two characters more (start insert mode, write, exit)." Makes sense. Asking for permission to type in a text editor feels counter-intuitive, but I'll give that a try.
- mcpherrinm 12y agoVim really is an editor: It's designed around changing existing text. Inserting new text is just one of the actions you can perform, and you can combine that action with other modifiers, like "5ifoo<esc>" results in foofoofoofoofoo -- 5 repetitions of "insert foo"
- dllthomas 12y agoThis goes better when you know (and have internalized) more of the paths into insert mode. 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 .
- chongli 12y agoOr 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<CR>" (excluding quotes). This will delete all text from the cursor to the first occurrence of foo.
- EdwardDiego 12y agoI'll have to remember that. Cheers.
- thegeomaster 12y agoNo need to use 1G at all, gg does the same and is one key less.
- zingar 12y agoIt 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.
- dllthomas 12y agoOr you're typing out a stream-of-consciousness thing. In which case you may be using vim correctly, but vim isn't buying you much.
- symmetricsaurus 12y agoI 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.
- csandreasen 12y ago> 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)
- kornerstoane 12y agoI was taught that one by the brother-in-law. He also tried to teach me 1234l (the letter 'l') to go to the end of a line. I figured out a better way pretty quickly on that one. 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 :)
- bphogan 12y agoI've been using vim for 5 years and a student showed me you can do it with commands too. :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.
- csandreasen 12y agoThat's actually kind of an interesting idea. $ for end-of-line always bugs me; for something so common I don't think it should require a chord. '999l' is pretty easy to tap out. 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)
- dllthomas 12y agoIs it common? It's really rare that I need to go to the end of the line and not switch to insert mode. If I do want to go to the end of the line and switch to insert mode, then what I want is A not $. Of course, there's a chord either way, but I'm surprised if you're finding it easier to type 999l than A.
- csandreasen 12y ago
- nakkiel 12y agoI 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.
- disputin 12y agoNow, 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 Interesting, I was thinking something similar - suitability for maintenance vs from scratch.
- afarrell 12y agoI use 'jj' rather than 'kj' and except for a pause after I type the first letter of 'join', it works well.
- StavrosK 12y agoInteresting coincidence, I was pasting a production certificate into Vim the other day and it contained "kj", which escaped the editor and ate a few letters until it reached an "i" and continued pasting. It took production down for 30 minutes until I noticed it. Remember, kids! ":set paste".
- jnetterf 12y ago"+p will paste the system clipboard.
- read 12y agoWhy is Esc-/ easier than Ctrl-f (or Ctrl-s in Emacs)? 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.
- Curmudgel 12y agoEfficiency really depends upon the keyboard you're using. If you use a keyboard with thumb clusters, the control and meta keys are under your thumbs and you don't need to twist your pinkies at all.