Live data from Hacker News

Learn Vim (the Smart Way): a book to learn the good parts of Vim

github.com

71–80 of 134 posts

Re: Learn Vim (the Smart Way): a book to learn the good parts of Vim

#71
post #55

I'm not trying to be contrarian here, but why would someone continue to use Vim and Emacs when all of its lovely features have been integrated into products like VCode? It just reminds me of serious men with beards working on mainframes and AIX power systems when I started my career.

Vim is just one piece of the puzzle, it's the editor in the IDE that is unix. Tools like VSCode and IDE's take over too many responsibilities and usually do an inferior job. VSCode will do the window management for instance, opening new tabs for files, file list windows, terminal windows, etc. My desktop environment (dwm or tmux) is much better at this and universal for non development tasks as well. Another bug bear of mine (this one doesn't apply to VSCode) is IDEs that want to be the build system instead of my much more powerful Makefiles.

Because it integrates so well into this environment it can be used as the editor step in other scripts/tools like how it is used in git commit messages. As a quick example of how this can be used here is a script I made for working with tab separated files:

  tmpout="$1.tmp"
  cat $1 | sed "s/\\t/~|/g" | column -t -s~ | \
  vim -c 'set nowrap' - +"file $tmpout"
  if [[ -f $tmpout ]]; then
         $1
        rm $tmpout
  fi
In 7 lines of code I made it a half decent tsv editor in part of a larger system, replacing the million excel windows others were using.

Re: Learn Vim (the Smart Way): a book to learn the good parts of Vim

#72
post #50

Earlier quoted context omitted.

I guess you mean you use them to insert ,s and ;s. But the leader key would not be for insert mode, so you can choose anything convenient.

No, I use them with the f and F keys. They repeat the previous character search in forward and backward directions.

I find rhysd/clever-f [1] to be more DWIM than Vim's default f/F.

    " 0: F is backward search, and repeating f after F searches in the same direction
    " 1: F is backward search, and repeating F after F searches in the same direction
    let g:clever_f_fix_key_direction = 1
[1] https://github.com/rhysd/clever-f.vim

Re: Learn Vim (the Smart Way): a book to learn the good parts of Vim

#73

Earlier quoted context omitted.

When I was first learning Vim I remapped caps lock to escape, and it was a huge improvement. But as I became more comfortable in Vim I realized I was using the control key a lot. I've since remapped caps lock to control, and use ctrl-[ as escape (this is default behavior). I find having an easily accesible control key is very useful, even outside Vim. You can see in your link that it is actually the control key that…

On Linux and Mac it’s possible to have caps be escape when pressed alone or control when pressed with another key. On Linux the software is called xcape. :)

[deleted]

Re: Learn Vim (the Smart Way): a book to learn the good parts of Vim

#74

Two things that helped me more than anything with "learning" vim and or ever wanting to use it: 1. Remap your "capslock" key to "escape." Vi was written using an ADM-3A terminal and its keyboard, which you can see here: https://catonmat.net/why-vim-uses-hjkl-as-arrow-keys has the escape-key in a sane place. On modern keyboards, if you can, remap "capslock" to "escape" when pressed alone, and "ctrl" when pressed with…

I'm personally a fan of remapping jk or jj to esc, there barely any instances in the english language where you would use those two letters together, and it means you can leave insert mode whilst barely moving your hands :D

I use zz, it's similarly rare and compliments ZZ (save and quit) well.

Re: Learn Vim (the Smart Way): a book to learn the good parts of Vim

#75

Two things that helped me more than anything with "learning" vim and or ever wanting to use it: 1. Remap your "capslock" key to "escape." Vi was written using an ADM-3A terminal and its keyboard, which you can see here: https://catonmat.net/why-vim-uses-hjkl-as-arrow-keys has the escape-key in a sane place. On modern keyboards, if you can, remap "capslock" to "escape" when pressed alone, and "ctrl" when pressed with…

Remap esc to ‘kj‘ instead. It’s faster to type than ‘jj’ it’s on the home row and doesn’t require a custom binding. The sequence kj is rarely used in English or coding.

Re: Learn Vim (the Smart Way): a book to learn the good parts of Vim

#76

Earlier quoted context omitted.

When I was first learning Vim I remapped caps lock to escape, and it was a huge improvement. But as I became more comfortable in Vim I realized I was using the control key a lot. I've since remapped caps lock to control, and use ctrl-[ as escape (this is default behavior). I find having an easily accesible control key is very useful, even outside Vim. You can see in your link that it is actually the control key that…

I recently learned this trick since getting a new MacBook pro with the touch bar esc key. I couldn't stand the lack of travel and didn't want to remap keys, now I use the ctrl-[ combo on all keyboards out of habit

Relevant to the other conversations going on in this thread, how simple is it to re-map that ctrl-[ to work globally? I'm assuming I'd have to install something for this. I am also using a Mac and use the caps-lock-as-escape to, say, close my spotlight search bar after activating it using the command+space shortcut.

Re: Learn Vim (the Smart Way): a book to learn the good parts of Vim

#77

Two things that helped me more than anything with "learning" vim and or ever wanting to use it: 1. Remap your "capslock" key to "escape." Vi was written using an ADM-3A terminal and its keyboard, which you can see here: https://catonmat.net/why-vim-uses-hjkl-as-arrow-keys has the escape-key in a sane place. On modern keyboards, if you can, remap "capslock" to "escape" when pressed alone, and "ctrl" when pressed with…

> Remap your "capslock" key to "escape."

Isn't it possible to configure vim to just use the actual CapsLock status for the mode switch?

Re: Learn Vim (the Smart Way): a book to learn the good parts of Vim

#78
About a month ago, I forced myself to try and use nvi, an (almost) narrowly compatible classic vi clone.

I thought of it as an exercise in constraint, with the aim of getting better at vim. Like vanilla vim without plugins, but Nightmare Difficulty.

I've now completely fallen for it. It's missing most mainstream features and still, I... like it more? I feel like a hipster typing this, but there really is a difference in brainfeel between using a ''huge'' editor I'll never grasp fully versus a tiny one I can learn completely. Tiny sparks joy.

Wikipedia entry on nvi: https://en.wikipedia.org/wiki/Nvi

Edits: grammar, punctuation.

Re: Learn Vim (the Smart Way): a book to learn the good parts of Vim

#79

Earlier quoted context omitted.

Picked up my vi chops at 38. The learning curve is admittedly steep, but you get past the curve pretty quick.

Ha, how about that. By the way, you might enjoy Lord of Light by Roger Zelazny. You're the hero of the story.

My parents named me after the main character, so you won't be surprised to hear that I've read it a few times, over the years.

Re: Learn Vim (the Smart Way): a book to learn the good parts of Vim

#80

Earlier quoted context omitted.

Ha, how about that. By the way, you might enjoy Lord of Light by Roger Zelazny. You're the hero of the story.

My parents named me after the main character, so you won't be surprised to hear that I've read it a few times, over the years.

Haha, figured as much. Well, good character to be named after.
Post reply on HN