Live data from Hacker News

Intermediate Vim

dn.ht

51–60 of 130 posts

Re: Intermediate Vim

#51
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…

instead of "52gg" I prefer ":52"

I prefer 52G. I guess it's not less keys since you're hitting shift, though.

Re: Intermediate Vim

#52
post #28

Earlier quoted context omitted.

I have capslock mapped to escape and never notice which one I use (started doing that after my escape key broke on a laptop about 15 years ago) I believe people with poor keyboards don't even have escape keys any more though

What do you mean by "poor keyboards"?

I imagine poor is a measurement of quality rather than personal wealth here. MacBook keyboards with the touchbar come to mind.

Re: Intermediate Vim

#53

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've used vim for a couple of decades, but never pushed to many advanced features. For your example above I'd do :%s/^/"/ and :%s/$/",/ Unless I use a feature regularly I find it's a higher cognative load. I use bash, sed and perl regexps on a near daily basis. Macros are very rare.

Likewise - with visual mode it's normally pretty quick to select an area and do a basic regex, even for things like re-indentation (auto-completes to something like :'s/^/\t/) even though I'm sure there's a 'proper' way to do that

Re: Intermediate Vim

#54
The balloon comparison is strange. I would've just said that adding shift to a shortcut often reverses it... / for search and ? for search backwards, alt-tab to switch windows, alt-shift-tab to go the other way, ctrl-tab to go to next tab in Firefox, ctrl-shift-tab for backwards. It's incredibly common.

Re: Intermediate Vim

#55

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 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 .

Re: Intermediate Vim

#56

The defaults in vim 8 in debian and ubuntu really changed the way vim worked, it was horrendous As far as I'm concerned, the following is an non-negotiable requirement for vimrc. source /usr/share/vim/vim80/defaults.vim set noincsearch set scrolloff=0 set mouse=

Just to extend this - if you're often using different users (or need to otherwise deploy via a configuration manager), I've found out that a good way of having system-wide options on Debian is /etc/vim/vimrc.local with something like:

   " Workaround stupid defaults.vim behaviour
   if filereadable("/usr/share/vim/vim80/defaults.vim")
      source /usr/share/vim/vim80/defaults.vim
   endif
   let g:skip_defaults_vim = 1
 
   " Disable stupid seeking to last position
   autocmd! vimStartup BufRead
 
   " Disable stupid mouse support
   set mouse=

Re: Intermediate Vim

#57
post #55

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 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

Re: Intermediate Vim

#58
post #28

Earlier quoted context omitted.

I have capslock mapped to escape and never notice which one I use (started doing that after my escape key broke on a laptop about 15 years ago) I believe people with poor keyboards don't even have escape keys any more though

What do you mean by "poor keyboards"?

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.

Re: Intermediate Vim

#59
post #28

Earlier quoted context omitted.

What do you mean by "poor keyboards"?

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 my MBP’s butterfly keyboard with Vim. Just please, don’t say keyboards are terrible after using for a few hours. There’s a reason why Apple is keep placing the butterfly keyboards in top-range Macbooks.

Re: Intermediate Vim

#60

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've used vim for a couple of decades, but never pushed to many advanced features. For your example above I'd do :%s/^/"/ and :%s/$/",/ Unless I use a feature regularly I find it's a higher cognative load. I use bash, sed and perl regexps on a near daily basis. Macros are very rare.

For that same example, you can accomplish the job in one substitute command:

    :%s/.*/"&",/
The & special character gets replaced with the whole matched pattern.
Post reply on HN