Neovim - how to do project-wide find and replace?

Поділитися
Вставка
  • Опубліковано 28 жов 2024

КОМЕНТАРІ • 27

  • @nikensss
    @nikensss 6 місяців тому +3

    I recently learned about `cdo` and I was just wondering `what's the difference between that and cdo?` haha and you just exaplained that in a very easy to understand approach. Thanks!

    • @benfrainuk
      @benfrainuk  6 місяців тому

      Excellent. Some good extra nuance in the gist by Integralist that’s linked in the description 👍

  • @dominykasbartkus1033
    @dominykasbartkus1033 3 місяці тому +1

    Thanks, that's very comprehensive.

  • @leiswatch8589
    @leiswatch8589 6 місяців тому +1

    Thanks for this video, great tutorial! I didn't know about cfdo, I have been using cdo, but it's time to change that :)

  • @driden1987
    @driden1987 6 місяців тому +1

    TIL update command exists. Thanks Ben.

  • @adheusrangel
    @adheusrangel 4 місяці тому

    Thank you! I've been postponing this learning for ages.

    • @michaelkastner3611
      @michaelkastner3611 3 місяці тому

      You're not alone. Been using (Neo)Vim for many years but never found a good explanation for global search. I'll frame this one.

  • @BhargavaMan
    @BhargavaMan 6 місяців тому +1

    Ben you're a legend

  • @OmGdoob
    @OmGdoob 4 місяці тому

    Thank you! Impressive tip!

  • @colin7270
    @colin7270 6 місяців тому

    Hi Ben, I saw your dotfiles repo is empty. Any plans to share your config? Looks clean!

    • @benfrainuk
      @benfrainuk  6 місяців тому

      Ah! Just added a link to the description. They are in a gist here: gist.github.com/benfrain/97f2b91087121b2d4ba0dcc4202d252f (ones that start x are unused plugins currently)

    • @colin7270
      @colin7270 6 місяців тому

      @@benfrainuk Thanks a lot! I appreciate this very much. Subscribed. :)

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

    I tend to use ambr for this kind of thing. Little unix utility written in rust.

  • @user-ot1dv6ri4f
    @user-ot1dv6ri4f 4 місяці тому

    does refactor in coc.vim not work in php?

    • @benfrainuk
      @benfrainuk  4 місяці тому

      Don’t use CoC. But LSP replace (assuming that is the kind of thing you mean) only works in certain languages, and of those, the ones you have an LSP installed for.

  • @norlock
    @norlock 6 місяців тому

    Why won't you use the LSP rename functionality? You basically use the LSP function to rename and don't have to worry about references that are not part of whatever you are renaming. Meaning if a local object has a similar name inside a function that needs to keep its name it won't change that. And LSP refactor is similar to a regular IDE rename function. I have the following keybinding: `vim.keymap.set('n', 'r', vim.lsp.buf.rename, {})` and then you do `:wa` to write to all the buffers

    • @benfrainuk
      @benfrainuk  6 місяців тому +1

      You don’t always have an LSP.

    • @norlock
      @norlock 6 місяців тому

      ​@@benfrainuk I do appreciate your time and effort, so keep up the good work 👍. But for most languages you have one (including PHP). The description + intro makes it sound that this is the way to do it in Neovim which is not really true, only in cases where you don't have a LSP for that project (obscure languages). Anyway still think this is interesting, but I just wanted to post this because the LSP rename function is much more convenient for most users.

    • @benfrainuk
      @benfrainuk  6 місяців тому +1

      @@norlockI use LSP rename plenty too but there are often occasions when I am working on a bunch of JSON and text files or just some random string that doesn’t sit well with LSP so need to do this on occasions where LSP won’t help

  • @Danielo515
    @Danielo515 6 місяців тому

    Is location list only for one file? So that is the difference...

    • @benfrainuk
      @benfrainuk  6 місяців тому

      One window as opposed to whole session. Here is a good overview with more info: freshman.tech/vim-quickfix-and-location-list/

  • @EpsilonKu
    @EpsilonKu 6 місяців тому

    I'm one of the devs of nvim-spectre (after inactivity of windwp). It's hard to keep it up. Maybe better people make replace and find without plugins tho. Let spectre rest, lmao.

    • @benfrainuk
      @benfrainuk  6 місяців тому

      I can imagine it’s often a thankless task, so thanks 🙏

    • @MagicDuckify
      @MagicDuckify 6 місяців тому

      Thanks for the work you do! Spectre can be a little buggy sometimes but its worlds better than the quickfix workflow. I think the idea of the search and replace ui as a buffer and seeing how your changes will look live is genius.

  • @adriansrfr
    @adriansrfr 2 місяці тому

    Instead of cfdo, why not bufdo?

    • @benfrainuk
      @benfrainuk  2 місяці тому

      Because the files are in the QuickFix list when I want to make changes to them

  • @Manmanolo115
    @Manmanolo115 5 місяців тому

    Cool and all, but typing the search term again is.. not so good