1.  

    This was something I was pleasantly surprised by when debugging some compiled Elm code in production. It’s cool how directly the source compiles to JS.. it made it fairly straightforward to figure out what was going on. Pretty smart decision by the Elm compiler authors I reckon!

    1. 14

      Intermediate vim stuff I regularly use:

      • Vertical split (:vs)
      • Ctrl-d/u to scroll up and down a half-page at a time
      • zz to center the viewport on the cursor
      • Pressing * on top of a word teleports you to the next instance of that word in the page.
      • Pressing % on top of a curly brace will teleport you to the matching curly brace. Works with other types of block delimiters, too.
      1. 3

        Yeah, these are all great!

        Another thing I really wanted to cover but didn’t quite get to was using . to repeat commands.

      1. 14

        Nice write up. I actually didn’t know about A, so I’ll be using that today. I usually do $i or $a to insert at the end of a line.

        52gg jump to line 52

        I might be wrong, but I think you can also do :52 to go to line 52.

        1. 10

          And also 52G

          (gg is a vim-ism, so if you’re just using plain old vi you need to use <number>G or :<number>)

          1. 10

            I might be wrong, but I think you can also do :52 to go to line 52.

            I love using this command. It is also possible to copy or move by expanding the command. Using :52co12 will copy line 52 to below 12. Using :52co. will copy below the current line. It even works with ranges :52,55mo. will move 52 through 55 to the current line.

            1. 10

              53,55norm! A; will at a semicolon to the end of every line in that range

            2. 3

              Thank you!

              Yep, I actually prefer the :52 style but I didn’t want to get into explaining : commands for beginners for this article. ;-)

              1. 1

                I usually avoid ‘$’ because I’m less accurate typing it haha!

                1. 3

                  I have a very small keyboard so R, $, and 4 are the same key, but with different modifiers.

                  1. 2

                    is it a Planck?

                    1. 2

                      Yup!

                      1. 2

                        I’ve been using one for more than a year now. I like it so much, specially that, by default, the escape key replaces caps lock, it’s perfect for vim.

                  2. 1

                    Cool kids do nnoremap L $.

                    1. 1

                      That’s a good idea. Unfortunately, I work in two separate vim-emulating editors which don’t support these gizmos.

                      1. 1

                        I actually use L M and H quite a bit, especially when I need to look at neighbouring code. I don’t use the split feature very often, though, do you?

                        1. 1

                          Even cooler kids do:

                          " Jump to first character or column
                          noremap <silent> H :call FirstCharOrFirstCol()<cr>
                          
                          function! FirstCharOrFirstCol()
                            let current_col = virtcol('.')
                            normal ^
                            let first_char = virtcol('.')
                            if current_col <= first_char
                              normal 0
                            endif
                          endfunction
                          

                          Explanation.

                          (I realise you were talking about nnoremap L $ and not nnoremap H 0, but I think the two ideas are related and I thought this might useful to somebody out there).

                          1. 2

                            That can be a lot shorter with expression mappings. This is what I map (to Home):

                            noremap <expr> <Home> col('.') is# match(getline('.'), '\S') + 1 ? '0' : '^'
                            imap <silent> <Home> <C-O><Home>
                            

                            Expression mappings are really useful!

                            Some other notes:

                            • normal means that Vim will use the currently mapped key, rather than the default one. So if you nnoremap 0 .... then your mapping may break since normal 0 will run that mapping. Use normal! to always ignore user mappings. You should almost always use normal! unless you have a specific reason not to.

                            • You can create a script-local function with fun s:FirstCharOrFirstCol() and then refer to it with nnoremap H <SID>FirstCharOrFirstCol(). I personally much prefer this as it doesn’t pollute the global namespace so much with what is essentially useless stuff.

                    1. 6

                      If this is “intermediate”, then there are at least 20 experts levels on top.

                      I don’t think it makes sense to look at lists of things you could do with vim. Instead observe yourself and look for one pattern you do often. Then research an optimization for that. Rinse. Repeat. Do it one by one. Vim is around for decades and it will still be there for you in a few years.

                      1. 6

                        I believe learning vim is a daunting task and tutorial resources which show off the power in a nice and friendly way can be a very good introduction to the subject. I see your point about observing and researching optimizations, but at first sight “modal”, “command mode” and even “:wq” might be too much for someone just trying to get their feet wet.

                        1. 2

                          Hey thanks, I appreciate it. :)

                          I’ve been pair programming a lot 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 folks who were new to vim found both text-objects and composing commands to be pretty mind blowing—so yep, this guide only barely scratches the surface but I just wanted to give newbies a taste for what makes vim so powerful.

                        2. 5

                          I don’t think it make sense to dismiss alternative presentations of information that don’t help you learn as unhelpful for everyone else. I’ve been using vim for just over a decade now, full time, and learned a couple of new tricks just by glancing over this article.

                          1. 3

                            I’m in the same position as you are. Have been using vim for a few years and I still learned something new which I can integrate in my editing workflow.

                          2. 3

                            I’ve been using vim for like 10 years and I don’t think I’ve ever used I, I use A constantly, but I always use 0 to go to the front of a line.

                            Never occurred to me to look for something because it feels find. I learned a lot by thinking “there should be a better way” and then finding it, looking at these kinds of articles every once in a while is useful for finding unknown unknowns.

                            1. 1

                              I’m similar. I use A all the time, and I know about I but yet I find myself doing 0i or ^i instead.

                          1. 4

                            We use buildkite for CI where I work at Culture Amp—it’s been a really really fantastic service and I’d highly recommend it.

                            We use it for builds and deployment and one great thing is it’s got some great options for autoscaling the number of build agents so you’re only paying for the resources you need.

                            1. 9

                              I made this little interactive notebook about drawing better looking Bézier curves: https://beta.observablehq.com/@dhotson/drawing-better-looking-curves

                              I’m also currently working on a plugin for Adobe Illustrator based on this. Screenshot: https://i.imgur.com/tIPTjLsr.png