Is there a way to make cursor make edits to multiple files?

for example, i want to refactor all my react file imports to be absolute path but it’s now doing relative path, can cursor do it? or maybe just renaming variables without relying on the editor.

sth like what https://sweep.dev/ does

1 Like

Interpreter mode…
But is limited to file length of roughly 250 lines…

1 Like

it would be neat also hopefully more lines are supported soon

1 Like

how are y’all using interpreter mode? the python script generated fails to run for me :joy:

Haven’t tried it a lot, but there is a multi-file edit function in Cursor Nightly:

Hope that helps :slight_smile:

2 Likes

huh weird! i don’t see that :thinking:

oh nice definitely will be using that

This is the Version I’m using:

Cursor Nightly

Version: 0.22.1-nightly

VSCode Version: 1.85.1

1 Like

sweep looks cool! linking this topic, which is a related feature request: Cursorbot: commit a PR from a GH issue

gotcha. we know about this and really do want multifile edits. the flow is tricky but we WILL make something work.

3 Likes

it’s definitely a hard problem to get the llm to keep track of where it is. i’m trying to do a multi-file edit in aider now, and it’s only able to edit ~3 files per commit, which i could live with, except that i cannot for the life of me prompt gpt-4 to reliably keep track of which files it has already edited. it very often repeats itself, or skips files entirely.

here’s another idea that might be more reliable: can i script Cursor? let’s say i want the same context and the same edit prompt for all files in a folder. can i just write a script that will get cursor to apply that to each file in a folder? the advantage of this approach is that you are using the script to do the procedural/algorithmic part, and just using cursor for the code-editing part (but not having the llm keep track of the process/sequence/procedure).

here’s my current implementation with Aider for this problem (which Cursor wrote for me, based on the Aider docs)

for root, dirs, files in os.walk(data_directory):
    for filename in files:
        print(filename)
        if filename.endswith(".txt"):  
            file_path_cwd = os.path.join(root, filename)
            print(file_path_cwd)

            command = f"aider --4turbo --openai-api-key {openai_api_key} {reference_file_path} {file_path_cwd} --message \"based on the information in reference_file, make xyz changes to this .txt file.\""
            
            # Execute the command
            os.system(command)

(right now it’s running them in sequence. i was too scared to test in parallel, for fear of a git nightmare, even though in this approach each file is modified by a separate Aider commit.)

it would be killer to be able to do something like this with Cursor.

EDIT: i later was shown that i didn’t need to write my own script for aider: Frequently asked questions | aider , this could be a cool direction for Cursor to explore. very powerful to combine scripts & codegen llms…

2 Likes

I also think it would be awesome scripting in cursor to automatize polished workflows mixing IA and regular scripting/cli commands

I need this so bad.

At the moment, this feature is only available in Aider.

It seems that something interesting is waiting for us.

Yeah, I’m experimenting with Aider and Deepseeker Coder to edit the files. Honestly, I’m tired of copying and pasting. I hope there’s something better in the future because the day someone has a better solution, I’ll switch.

2 Likes

Is multi-file edits still not a feature? I tried asking it

For every file that is using X but lacks the import statement, “Y” - can you add it?

But all it does is look at the current file I’m on and end there. I thought multi-file edit was a recent feature.

Ah, nm, I think I found it: Multi-file edits - 0.37 update. I’ll add this report there.