4 ms·
Since I was in university 15 years ago I promised myself to learn Vim commands seriously. Well I see that finally I did my programmer life learning only switch
by somecommit 5y ago
Since I was in university 15 years ago I promised myself to learn Vim commands seriously.
Well I see that finally I did my programmer life learning only switching insert mode / edit mode, maybe 5 commands like A x etc...,and :q or :wq!
- dskloet 5y agoPlease learn dot ".". It repeats the last edit action. It's so powerful.
- mbwgh 5y agoI use macros way more often than dot. With a macro I can include the movement action of getting to the correct position before the edit takes place, I'm not sure if this can be done with the dot key alone.
- johncoltrane 5y agoWhether one uses . or a macro (manual or recorded) should depend on the current situation. It's really not a "pick one and stick with" it kind of situation.
- Lio 5y agoI agree, so many ways to do it it’s horses for courses. Eg from the first “pick” you could press * to highlight occurrences and move to the next one use cw to change it to “s” and bounce on n to move to the next one you to squash and use . to repeat the change. That’s visual and lets you decide which commits to squash. If I wanted to squash all the other commits I’d probably use visual block and } instead, but that’s just me. I’d save a macro for more complex edits.
- ohmahjong 5y agoI relate quite heavily to this when using vi to do all my git-related activities. git rebase -i ... followed by ↓dw ↓←dw ↓←dw ↓←dw ↓←dw ↓←dw i s ↓s ↓s ↓s ↓s ↓s because I keep forgetting :s/pick/s/g is a thing i, a, :q, :wq, dd, xdd, and D are all the ones I remember, but cutting/yanking pasting is still something I don't have the muscle memory for. Shift+G takes me to the bottom of a file, but I don't know how to get back to the top :D . I really need to make time for vimtutor and commit to it.
- aulin 5y ago> Shift+G takes me to the bottom of a file, but I don't know how to get back to the top :D mostly emacs user here, but when I'm on vim I use :0 and :%
- tuxlifan 5y agoI'm guessing you want :%s/^pick/s/ to replace "pick" at the start of line with "s" on all lines? If you execute it once in vim you can recall it later with just typing :%↑ and confirm with Enter. As for the top of the file: gg I use the mnemonic "go go line" (as in Inspector Gadget's "go go gadget") and since you can prefix it with a line number (e.g. 4gg to go to line number 4), leaving it out gets me as close to line number nothing^Wzero as possible, i.e. line 1. HTH :) PS: the % says "on all lines" your trailing "/g" would make it match&replace "pick" multiple times on the (current, since % is missing) line PPS: As an aside, I use "vim somefile +N" all the time to open somefile at line number N; especially when there's an error message in the form "error at somefile:N" by typing vim, then double-click-middle-click copy&pasting "somefile:N", Ctrl-E to jump to the end and replacing ":" with " +". I really should write a shell function for that... EDIT: formatting
- ZeroGravitas 5y agoVim has some built in support for that syntax https://github.com/Konfekt/vim-compilers https://github.com/Konfekt/vim-compilers
- Jare 5y ago> Shift+G takes me to the bottom of a file, but I don't know how to get back to the top :D I know the complement to Shift+G, it's gg. But I can never remember which one goes to the top and which to the bottom, so half the time I press both. :)
- pjungwir 5y agoG takes a line number as its "object" like other vim commands. So 1G is the first line, 10G the tenth, etc. G is the last. (0G goes to the last line too.)
- 5y ago