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.

2 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…

1 Like

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