Open vgezer opened 3 months ago
I can send a pull request for underscore
You might want to move the editor setting to the "Behavior" category, instead of "Appearance" where it does not really fit.
Other than that, I'm totally in favor of adding an option for this + the linked issue by Calinou.
Many editors feature a "word separators" setting which is a list of non-whitespace characters that are used as word delimiters. It's usually a string of the form code>`~!@#$%^&*()-=+[{]}\|;:'",.<>/?</code (this is the default in VS Code).
Characters that will be used as word separators when doing word related navigations or operations.
Here we go: https://github.com/godotengine/godot/pull/92514
It would also be possible to add a separate shortcut for word parts like ui_text_caret_word_part_right
. VSCode has something similar, with no default binds.
Many editors feature a "word separators" setting which is a list of non-whitespace characters that are used as word delimiters. It's usually a string of the form
`~!@#$%^&*()-=+[{]}|;:'",.<>/?
(this is the default in VS Code).Characters that will be used as word separators when doing word related navigations or operations.
I replaced these characters with ´`~$^=+|<>
because even without my commit, the other characters are treated as word delimiters and there is no way to ignore them with my PR.
Describe the project you are working on
It is actually not a project, but a generic idea to improve code editor on Godot itself.
Describe the problem or limitation you are having in your project
I like the way of using keyboards on IDEs for almost anything as if I am on a console/terminal.
For example, duplicating lines, deleting a word, deleting from cursor, or deleting until cursor using keyboard increases my productivity speed.
Some IDEs detect the words on variables/functions even there is no space between them:
and this allows easier and faster editing the words partially. Let's see the current situation in Godot:
I have this variable:
this_is_my_very_long_variable
. I would also like to createthis_is_his_very_long_variable
as a second variable. What I can currently do in Godot is to copy it or use auto-completion by typingthi
. Then moving caret left until I reachmy
and replacing it withhis
. Alternatively, I can click with mouse, but it is not practical.Describe the feature / enhancement and how it helps to overcome the problem or limitation
If we make editor also capitalization or underscore aware, then, if I want to just edit the middle of a long variable, I can just use the Ctrl+Left or Ctrl+Right to jump to the location where I need to modify. In the example above, I can just use Ctrl+Left 4 times.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
In text_edit.cpp,
I modified the
_move_caret_right
and_move_caret_left
functions to consider the option to stop if it detects an underscore, if it is enabled in editor settings.Here is what it looks like in the editor settings:
If this option is enabled (it is disabled by default), copying and pasting the line, then using Ctrl + Left 4 times moves the caret to:
If I then keep Shift pressed then use Ctrl+Right, I just mark "my" and easily change to "his".
I already have the diff to integrate the underscore version. If it is found to be useful, I can send a pull request for underscore. Then, one can improve it to detect case differences to move caret in these cases as well.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Not with scripts, but using Left key multiple times.
Is there a reason why this should be core and not an add-on in the asset library?
This is a generic productivity enhancement, not project specific.