Live data from Hacker News

Intermediate Vim

dn.ht

61–70 of 130 posts

Re: Intermediate Vim

#61
post #57
post #55

Earlier quoted context omitted.

I use the . (dot) command a lot out of habit. It executes the last command. If the last command was a macro execution, dot doesn't execute the macro - it executes the last command of the macro. Is there a way to fix this? edit I see someone else answered this - use @@ instead of .

@@ repeats the last macro

Yep, and you can just hold down @ to blaze through many lines. If you overshoot, just undo a bit.

Re: Intermediate Vim

#62
post #6

Hey all, I'm the author. Feedback is welcome! :) The reason I wrote this is because I've been pair programming quite a bit lately and also mentoring some new vim users—so I wrote this little guide to help vim beginners level up their skills a bit. What I noticed is that a lot of vim beginners find composing commands and text-objects to be kind of mind blowing.. and even more experienced vim users mentioned that these…

Visual mode is a good next step after getting comfortable with b,w,e,h,j,k,l navigation.

Re: Intermediate Vim

#63
post #6

Hey all, I'm the author. Feedback is welcome! :) The reason I wrote this is because I've been pair programming quite a bit lately and also mentoring some new vim users—so I wrote this little guide to help vim beginners level up their skills a bit. What I noticed is that a lot of vim beginners find composing commands and text-objects to be kind of mind blowing.. and even more experienced vim users mentioned that these…

Nice checklist... I'm not quite convinced about this as general advice : > If you’re like me and never learned to touch type properly, just use the arrow keys, it’s fine, don’t worry about it. When I decided to go all-in on Vim keys some time ago (trying to find plugins for everything), it didn't take long to transition to hjkl. I think it's easier and more convenient to stay near the home row rather than moving my h…

Agreed, vim is extra arcane if you avoid home row. If you don't use the home row much there are probably more suitable editors out there.

Re: Intermediate Vim

#65
A well written guide for introducing some of the power of Vim to a new user.

One thing I'd suggest for the author, based on a quote from the article - "Invest your time to learn new skills" - Try and invest some time to learn touch typing.

I worked as a developer for years thinking that it wasn't worth the effort, but after taking a couple of weeks to learn, I never looked back. My productivity, particularly with Vim has jumped leaps and bounds.

Re: Intermediate Vim

#66
post #24

Earlier quoted context omitted.

I was going to say that one annoying thing about these macros is you can't press . to repeat the last macro. It is annoying having to count out 143 lines and then do 143@x or what I tend to do is do it in batches of say 20 until I get to the end.. But this has prompted me to look this up and it turns out that you can use @@ to do this. This will make my life a lot easier, I can just smash until all my lines are updat…

Another notable trick is that vim registers are case-insensitive -- and since macro's are just stored in registers, macro's are case-insenstitive as well. so @q == @Q, which alleviates some of the RSI problems with spamming @q.

I remember something about a capital register appending instead of overwriting -- is that only for saving (with no influence in execution)?

Re: Intermediate Vim

#67

Earlier quoted context omitted.

My collegues are constantly complaining their (mac) laptop keyboards are terrible, however aren't ballsy enough to say "F-U" to the corporate choice of a mac or a windows laptop.

Well, HNers complains the MacBook keyboard as it’s a complete trash, but please remember that there are plenty of people that likes and even loves the butterfly keyboard. The keyboard itself is pretty awesome and provides much stabler keys than usual keyboards (whether it’s membrane or mechanical). They work regardless of what part of key I press, which means that typo rates significantly decreases. I’m happily using…

I'm not saying it, the people using them all the time are saying it.

I'm happy with the generic HP keyboard I'm using at the moment, circa 2014, and my T410s old style thinkpad keyboard.

Re: Intermediate Vim

#69

Maybe you can cover macros since they are conceptually very simple and very powerful. They may seem a bit complex but are quite simple. Basically you just record your editing movements and play it back. How macros work: press q x to record and q to end. Then repeat with @ x, where x is the name of the macro you want to use (you can have several macros). Anything you do will be played back. That's it... Conceptually s…

this is somewhat shorter: qq0i" A", jq@@ i agree this example is silly. i'd do something like :%s/.*/"&",/

Yeah, it is a toy example on purpose.

Macros really shine when you need to do a bit more complex stuff, there is certainly a cutoff between ease of regex "from the top of my head" vs. spending time formulating it.

Re: Intermediate Vim

#70

Maybe you can cover macros since they are conceptually very simple and very powerful. They may seem a bit complex but are quite simple. Basically you just record your editing movements and play it back. How macros work: press q x to record and q to end. Then repeat with @ x, where x is the name of the macro you want to use (you can have several macros). Anything you do will be played back. That's it... Conceptually s…

I also use a lot of macros. I just learned that macro registers are the same as regular registers, so you can actually paste the contents of a macro and examine it or save it to a file (e.g. "xp after recording your macro).
Post reply on HN