Fork me on GitHub

I am in need to do a refactoring across many files. Go from (defn foo [{:keys [show]}] …) to (defn foo [{:keys [showing]}] …), so essentially rename an argument of a function and its callers. Is this something clojure-lsp could provide?


I don't know the answer to that question, but I do feel like sharing the way that I typically handle things like this, because I think it's a nice, pragmatic solution and I've never found it cumbersome, even in large code bases. I use to search for all instances in the code base of a unique (or as close as I can get to unique) string. Then, I either go through and fix them one at a time, or if there are a ton of them, I might do %s/thing/replacement/g in the results buffer, which ctrlsf handles nicely by saving my changes to each file. I find ctrlsf utterly indispensable. I use it so often that I've defined a couple of mappings for convenience: <leader>f runs :CtrlSF<space> so that I can type in the string I have in mind and press enter. In visual mode, <leader>f runs :CtrlSF <my selection><Enter> so that I can highlight one instance and search for all instances across the code base.


I use a similar approach with and, complete with a couple of custom mappings too 👌

💯 1

It's also a nice solution because it works in any code base in any language, not just Clojure.


Another thing I'll do on rare occasions where there are a ton of instances and the replacement is straightforward, is write a Bash script using find and sed -i


I don't think clojure-lsp can do that yet @orestis. This is returned when I try to rename keys in a map or keys that are being destructured: [coc.nvim] Invalid position for rename


I also use fzf together with the quickfix window to visit multiple files, but I confess that for this instance I went into vscode and used the mouse 🙂


bufdo is my goto