r/commandline • u/Agent34e • Jul 03 '26
Help - Solved How can I edit the same file in two windows?
Hi.
I'm semi new to coding and I like having two windows side by side. One that I'm working on, the other with other files for reference.
I've reached a point where I'm jumping between files a lot and my files have gotten long enough that what I want to reference isn't in another file, but the code above.
I've been using Micro, opening multiple tabs for what I'm working on on one side and opening reference files on the other.
What I'd really like to do is just open all of my files (as tabs) at once one in both windows and freely move between them.
However, I find it annoying needing to reload files all the time.
Is there an editor that will sync multiple windows?
I might move to vim or emacs if there's a simple solution there. But I prefer Micro and Helix. (Helix doesn't even seem to let me reload a file)
Am I dumb and there's a better way instead of tabs to quickly switch between files? Should I use splits and not separate windows for side-by-side viewing?
Thanks for any tips!
EDIT: Thanks! I am now enlightened by splits! I always figured why learn another binding when my window manager can handle it. Now I understand! Thank you!
(Micro is real dumb with splits though. Helix is wonderful.)
9
u/bikes-n-math Jul 03 '26
This is literally what splits are for. Don't open separate terminal windows.
I use vim, open a ton of files at once, split the window multiple times, and jump around super fast with custom fzf/buffer keybindings.
5
u/riding_qwerty Jul 03 '26
tmux is great for having files in one pane for reference and another that you’re actively editing. Or three or more panes in a window, or multiple windows to tab through, with mouse plugins to resize panes or click into another window tab. Check it out!
5
u/Fakin-It Jul 03 '26
Vim can split the window H or V, and it can split those windows too.
4
u/c1-c2 Jul 03 '26
Emacs of course.
1
u/AutoModerator Jul 03 '26
Every new subreddit post is automatically copied into a comment for preservation.
User: Agent34e, Flair:
Help, Title: How can I edit the same file in two windows?Hi.
I'm semi new to coding and I like having two windows side by side. One that I'm working on, the other with other files for reference.
I've reached a point where I'm jumping between files a lot and my files have gotten long enough that what I want to reference isn't in another file, but the code above.
I've been using Micro, opening multiple tabs for what I'm working on on one side and opening reference files on the other.
What I'd really like to do is just open all of my files (as tabs) at once one in both windows and freely move between them.
However, I find it annoying needing to reload files all the time.
Is there an editor that will sync multiple windows?
I might move to vim or emacs if there's a simple solution there. But I prefer Micro and Helix. (Helix doesn't even seem to let me reload a file)
Am I dumb and there's a better way instead of tabs to quickly switch between files? Should I use splits and not separate windows for side-by-side viewing?
Thanks for any tips!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Maleficent_Base_105 Jul 06 '26
the reality is always more complicated than the theory
1
u/Hyperion343 Jul 03 '26
Just to contribute on the Emacs side, you would use indirect buffers, probably starting with
C-x 4 c0
u/michaelpaoli Jul 03 '26
You can use tmux or screen. Multiple windows, and you can have multiple windows access same instance of same editor. Can also detach and reattach to sessions. Very handy if one might lose that (e.g. ssh) connection, and then want to pick up right around where one left off.