How Neovim saved me at least 30 minutes today

Поділитися
Вставка
  • Опубліковано 26 чер 2024
  • Dotfiles: github.com/JRasmusBm/dotfiles
    CHAPTERS
    00:00 Preamble
    01:57 Recording the macro
    03:20 Using the macro
    03:49 Cleaning up the object
    04:15 Setting up the argslist
    05:02 Fixing formatting issues with argdo and prettier
    06:14 Adding imports
    07:30 Conclusion
  • Наука та технологія

КОМЕНТАРІ • 60

  • @hydranooni
    @hydranooni Місяць тому +5

    Very underrated channel! Need more of this advanced Neovim tips and tricks! Keep going man

  • @JustSomeAussie1
    @JustSomeAussie1 Місяць тому +5

    first time seeing argdo and arglist. pretty cool

  • @sondrefjellving
    @sondrefjellving Місяць тому +9

    This is very impressive. Looking forward to seeing more! 👏🏻

    • @JRasmusBm
      @JRasmusBm  Місяць тому +2

      Thank you for the kind words! I'm standing on the shoulders of giants! 😇

    • @sondrefjellving
      @sondrefjellving Місяць тому

      @@JRasmusBm I started using vim earlier this year because someone at work recommended trying it out. I'm loving it so far and have seen a massive increase in productivity, but I am currently just using vim-extension in my IDE.
      Your workflow with neovim looks so smooth and satisfying though, so I will have to look into it sooner or later. Subbed for more inspiration

  • @valid_
    @valid_ Місяць тому +5

    Taught me about the arglist, thanks a lot.

    • @JRasmusBm
      @JRasmusBm  Місяць тому +1

      Happy to help! 😃

  • @karthikeyanparasuraman9337
    @karthikeyanparasuraman9337 Місяць тому +7

    Crazy!!! I need more of these!

    • @JRasmusBm
      @JRasmusBm  Місяць тому +2

      Thank you for the encouragement! 😃
      The main challenge is that I do most of the big impact stuff on proprietary code. I'll try to find more examples that I can extract and recreate 👍

    • @Axlefublr
      @Axlefublr 15 днів тому +1

      @@JRasmusBm finding good examples is 100% the most difficult part in showing off vim features effectively ime

  • @jeroenvermunt3372
    @jeroenvermunt3372 Місяць тому +10

    argdo seems fire

    • @JRasmusBm
      @JRasmusBm  Місяць тому +2

      All of the *do commands (argdo, ldo, cdo etc.) are indeed 🔥

    • @mkamp
      @mkamp Місяць тому +2

      Maybe break that down in another video with more time?

    • @JRasmusBm
      @JRasmusBm  Місяць тому +4

      @@mkamp Great question! 😀
      They will probably come up in later videos. In the meantime you can read about them in the vim manual under:
      :help :cdo
      :help :ldo
      etc.

  • @jonathanjohnston9272
    @jonathanjohnston9272 11 днів тому

    Nice video. Thanks! I've been using Vim since about 1996, but I don't think I ever tried combining argdo & normal. I need to give that a try :)

  • @Aucacoyan
    @Aucacoyan 15 днів тому

    Thank you! I saw many features I didn't know it existed in Vim

    • @JRasmusBm
      @JRasmusBm  15 днів тому

      Happy you found some inspirational takeaways. Thank you for watching! 😇

  • @jawee15
    @jawee15 28 днів тому +3

    Not sure if you know this and I missed the point of going to the beginning of the line by pressing 0 in the macro, you could've just pressed _ (underscore) to go to the first non-whitespace character on the line. :)

    • @JRasmusBm
      @JRasmusBm  28 днів тому +2

      That's a great point! I used to override that with a mapping and use ^ for the same operation, but in these scenarios it would indeed be very useful. I'll start using it.
      Thank you for watching and commenting! 😃

  • @relaxgameing8395
    @relaxgameing8395 25 днів тому

    Now I really want to learn using macro like this ❤

    • @JRasmusBm
      @JRasmusBm  15 днів тому +1

      This inspires me to make a video on the topic at some point. Thank you so much for watching! 😇

  • @Jir-9001
    @Jir-9001 16 днів тому +1

    what a beast! i didn't even knew i could do that LOL feeling stupid right now

  • @yashjajoo6752
    @yashjajoo6752 25 днів тому +1

    Hey, amazing video! Everytime i think I know vim enough a new bunch of things open up. This video was really an eye opener. I wanted to know at 4:05 how did you set the range for sort. I could see the cursor was at the last word in the object. but The way would be to go to Pizza type 19 and then :, the specified range comes. How did you select the range from the Word burritos

    • @JRasmusBm
      @JRasmusBm  24 дні тому +1

      Happy you enjoyed it! 😃
      I used !i{ to prepare to pipe the lines between the curly braces through the sort shell command and back into the buffer. Hope this helps!

  • @NemyVJ
    @NemyVJ 28 днів тому

    Great video very cool tricks! Btw how do you get suggestions what to write in your terminal? For example at 4:24?

    • @JRasmusBm
      @JRasmusBm  24 дні тому +1

      Thank you for watching and commenting!
      I think it's this line. github.com/JRasmusBm/dotfiles/blob/7b63fc4d57175238c6f51eb0b19b517b17971089/shell/zshrc#L23

  • @DJRanoia
    @DJRanoia Місяць тому +1

    I do have a question. I’m trying to watch you ca the function how did you remove the function using the f key when you did caf ? I would have thought you would have to ca( to achieve this or something similar did you customize anything for this?
    Edit:
    Oh, I think I found it. It’s a plug-in called nvim-treesitter-textobjects
    Is that what you use?

    • @JRasmusBm
      @JRasmusBm  Місяць тому

      Yes indeed, nice research! My config for it is in the following files:
      github.com/JRasmusBm/dotfiles/blob/main/vim%2Flua%2Fplugins%2Fnvim-treesitter.lua#L16
      github.com/JRasmusBm/dotfiles/blob/main/vim%2Flua%2Fjrasmusbm%2Ftreesitter%2Fselect.lua#L7-L8

    • @DJRanoia
      @DJRanoia Місяць тому

      @@JRasmusBm Thanks! Took a few ways of wording it but finally figured it out when googling. Then I had to figure out how to modify my lunarvim 0.10 setup to append that to the treesitter config that is in the core of the project. All good now! I've been having fun testing it on different langauges.

  • @JohnFarrellDev
    @JohnFarrellDev Місяць тому +1

    Cool video but 1 question, why does each food need its own component or is this just for demo purposes? Otherwise surely pass the Food in as a prop.

    • @JRasmusBm
      @JRasmusBm  Місяць тому +1

      They created SVGs, which could be tweaked (sometimes a lot) by the props. These were vastly different in terms of implementation and not possible to generalize further.

  • @Axlefublr
    @Axlefublr 17 днів тому

    What's the plugin you're using for the floating command mode window?

    • @JRasmusBm
      @JRasmusBm  15 днів тому

      Noice.nvim - Though I am still on the fence whether it's an improvement to my workflow 😂

    • @Axlefublr
      @Axlefublr 15 днів тому

      @@JRasmusBm it looks, as the name suggests, noice! thank you, I'll check it out :3
      command mode has always looked kinda too bland to me in terms of visuals, maybe I'll prefer the floating window more

    • @Axlefublr
      @Axlefublr 15 днів тому

      @@JRasmusBm also while you're here: thank you for the content!! it's difficult to find people making content on the more in-depth vim usage tips and tricks, so I appreciate it a lot. I also make similar content on my channel, cause I can never get enough of vim magic hehehe

    • @JRasmusBm
      @JRasmusBm  15 днів тому +1

      @Axlefublr Thank you for sharing your channel! I agree it's very difficult to find more advanced (neo)vim content 👍
      I watched a few videos (really liked the one on registers) and am sure to be watching more. 😇

    • @Axlefublr
      @Axlefublr 15 днів тому

      @@JRasmusBm hell yeah! for the most up-to-date content, I only stream nowadays. The most recent stream contains 2 whole hours of really cool and powerful stuff! As a slight spoiler, one of them is a way to execute a command over all lines in the file, except for some *arbitrary* lines. A way to do :%command, but with exceptions!

  • @abrarmasumabir3809
    @abrarmasumabir3809 Місяць тому +1

    what font are you using?

    • @JRasmusBm
      @JRasmusBm  Місяць тому

      Had to look it up. I don't care much. Apparently it's Jetbrains Mono.
      Config here: github.com/JRasmusBm/dotfiles/blob/main/terminal%2Fthemes%2Fdark.yml#L3-L16

  • @Qrzychu92
    @Qrzychu92 8 днів тому

    while I understand that this is fun, and honestly quite smart... I can't stop thinking about the fact that this is just a refactoring in Intelij :D alt+enter, enter, repeat 20 times (or record a macro if you have vim mode :P)
    I cannot understand why people think that manually pasting the imports with changed path like this is better than "Refactor -> move to new file".

    • @JRasmusBm
      @JRasmusBm  6 днів тому

      That sounds really cool! Does the Intellij Vim plugin support recording "extract to file" as a macro?
      I agree that a prepared programmatic way of doing this would be even better, if it does what you want and can be done at the same speed to 50 components. How does that refactoring work? Does it make up a file name or do you specify it?
      Regardless, thank you for commenting and sharing!

    • @Qrzychu92
      @Qrzychu92 6 днів тому

      @@JRasmusBm well, I would just press alt+enter 50 times personally...
      BUT, vim mode in Intelij allows you to trigger IDE commands just like vim commands, so I think it's doable to do a macro "extract component refactoring, move one line down"
      haven't tested it, but in principle should work

  • @damilolaowolabi9148
    @damilolaowolabi9148 Місяць тому +1

    Can you show us how you set up DAP for typescript and js?

    • @JRasmusBm
      @JRasmusBm  Місяць тому

      Transparently, I have not taken the time to get that working properly for TypeScript. If I ever take the time and get it working, I'll make a video 👍

  • @chudchadanstud
    @chudchadanstud 4 дні тому

    why didn't you just put that in a database? How did this become a thing?

  • @barterjke
    @barterjke 22 дні тому +1

    It's honestly very impressive, you apparently know vim extremely well. But that's said, vim didn't save you a lot of time, at least at this scenario. Any modern editor has features like multiline editing, jump to an end/start of the line and jump over words. Combination of those could pretty much do the exact same work for you - minus creating files and some copy pasting. And also you could just use any scripting language to do the very same thing.
    But again, it's still impressive, I can't that much.

    • @JRasmusBm
      @JRasmusBm  22 дні тому

      I appreciate the perspective! It's true that I could have done many of the same things in other editors. I find the multi-cursor feature of many modern editors very cool indeed.
      Great idea with the script. While I did consider that as well. the main challenge I was anticipating was the complexity of parsing out the functions. As the title of the video suggest, in my estimation that solution would have taken around 30 minutes to get right, instead of 3 minutes (I was lucky - it worked first try with the macro).
      Thank you for watching and commenting! And if you have productivity tricks from whatever tools you prefer using, please share! 😄

  • @RazoBeckett.
    @RazoBeckett. Місяць тому +2

    Lord green screen

  • @squishy-tomato
    @squishy-tomato 28 днів тому +1

    I'd refactor the code to reuse the same component instead of 50 nearly identical ones. But cool trick I guess.

    • @JRasmusBm
      @JRasmusBm  28 днів тому

      In the real code base at work these components are vastly different and cannot be abstracted or simplified further, even if they're all used in the same way. That's why this pattern makes sense to us.
      I would totally agree with you otherwise, thank you for watching and commenting! 😃

    • @squishy-tomato
      @squishy-tomato 28 днів тому

      @@JRasmusBm that makes sense

  • @avwie132
    @avwie132 Місяць тому +1

    This seems like absolute junior react code though. And every basic IDE can handle this just fine

    • @JRasmusBm
      @JRasmusBm  Місяць тому +1

      To each their own, we've found the pattern very useful. 🤷‍♂️
      Great to hear that you can do this as efficiently in your IDE. I have a deep interest in dev tooling, so if you were to make a video showcasing how do this in a different editor, I would be down to watch that 👍

  • @henrikholst7490
    @henrikholst7490 Місяць тому

    I think this proves that Vim macros are not worth it. :) sure, it can be more fun to do it in another way like this but overall it's a nisch thing to do complex vim macros.

    • @JRasmusBm
      @JRasmusBm  Місяць тому +2

      It's a valid question to reflect on, as most people discussing macros (I'm guilty as well) show of the niche and the flashy changes. 👍
      There's one core aspect of video creation in this argument. Creating a video like this implies creating safe reproductions of proprietary code, which is a non-trivial amount of effort. Even if it's a colleague or friend that takes the effort to show off these tools, the same is contributing non-trivial effort by reaching out at all. Thus I would argue that the fact that most displays of Vim macros are niche and flashy are likely a result of selection bias towards the flashy and the uncommon.
      I use Vim macros (and their cousin, the :norm commands) at least every 5 minutes throughout the day. The aggregation of simple macros is much more impactful than these flashy ones, and I would argue emphatically that macros are worth learning.
      That said, I'm not here to convince anybody, I'm just making the kind of content I wish existed when I was learning Vim about a decade ago.
      Thank you for watching, and for your perspective! 😇

    • @henrikholst7490
      @henrikholst7490 Місяць тому

      @@JRasmusBm I am a big fan of recreational programming videos like this. The entertainment of watching and sometimes learning something new, useful or not, is a positive. I just think that the way macros are implemented in Vim is suboptimal and the complexity and risk of getting it wronge is very high. perhaps it would be better with a DSL (Lua more likely) that I could run that interacted with the LSP or AST from treesitter...

    • @JRasmusBm
      @JRasmusBm  Місяць тому

      Haha, I am hoping to end up more educational than recreational, but anywhere on the spectrum is fine 😇
      On the topic of macros I have way too much to say for a comment 😊 Might make videos on the topic.
      My firmly held belief (maybe controversially) is that sequences of vim keystrokes (i.e. the source of macros) is an amazingly expressive and extendable DSL for text manipulation.

  • @tokiorys
    @tokiorys Місяць тому +1

    So you've just spend 8 of 30 saved minutes to show how you use neovim)
    Average Neovim user

    • @JRasmusBm
      @JRasmusBm  Місяць тому +3

      Wrong on both points. I spent a lot more than 8 minutes making the video, and I don't consider myself your average Neovim user.😛
      I don't care much what tools you use. Neovim has had a huge impact both on me and my career. I am standing on the shoulders of giants, and I am making content that I wish existed when I started using the tool.
      Thank you for watching and commenting! 😇