gitui
gitui copied to clipboard
Open editor in the same line of the diff pane
During diff inspection, it would be nice to open the editor to the same line number as it is within the diff pane. This feature would allow to quickly make changes to the file under inspection.
It would be also very useful to print numbers at the begin of the lines in the diff pane.
Thanks for your awesome work.
that has two challenges:
- we open any editor configured via environment variables
- we could probably pass on some variable that works with vi but what happens if someone has other editors convigured?
We could check the $EDITOR or $GIT_EDITOR for a handful of most common editors and support that? E.g. vim, nvim, vi, nano, emacs, subl, vscode, they all support something like <editor> +<line> <file>.
If it's not one of those, we could read a config entry in the form of <editor> <args> <file> and let the user provide their own?
IMO it would be a reasonable compromise to have this feature for all editors supporting the +line arg.
I assume that with the editors just enumerated you already covered a huge part of gitui users (maybe all :-) )
I have found myself wishing for this feature fairly often since it's great to be able to live inside gitui!
The most satisfying and flexible way I've seen this problem being solved is the token-based approach in qutebrowser for defining an editor command via config:
https://www.qutebrowser.org/doc/help/settings.html#editor.command
... The following placeholders are defined:
{file}: Filename of the file to be edited. {line}: Line in which the caret is found in the text. {column}: Column in which the caret is found in the text. {line0}: Same as {line}, but starting from index 0. {column0}: Same as {column}, but starting from index 0. ...
This method allows for configuration that would work with almost any editor. We also probably wouldn't need column or column0 here.
There could still be default configuration similar to the current functionality, but with the ability to override beyond just setting an environment variable. The +line could even be part of the default configuration, like:
editor_command: "$EDITOR +{line} {file}"
The big caveat of this idea/suggestion being that from what I know gitui doesn't currently have anything like a config.ron, but we do have config files for themes and keybinds.
This issue has been automatically marked as stale because it has not had any activity half a year. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
not stale? 🤞😃
Any update on this? I just started using this amazing software (good job with this project BTW! :D) but this part is quite frankly really annoying, when working with decently sized files this problem causes quite a lot of wasted time having to scroll to the line you were on when you pressed "e" to edit the file while on gitui, is there any chance this might get implemented using one of the suggested possible solutions (or something else) in the future?