It seems that 'quick add next' and 'expand selection to word' are both mapped to the same key binding.
I am not sure how to override/change the 'expand selection to word' because I cannot find the current key binding for both actions.
Does anyone know what the two actions are called?
Just to clarify, let's say I have the following block of code
this.GRID_TOP = 10;
this.GRID_SPACING = 10;
this.GRID_HEIGHT = 10;
this.GRID_WIDTH = 10;
I want to select the 'GRID' string on each line. I could use alt+F3 but that's overkill. I want to select 'GRID' then hit ctrl+D to select the subsequent matches. My problem is that it works once (selects first two) but then expands both cursors to the end of their words. Since the selections are now different, I cannot 'quick add next'.
Ctrl + D in SublimeText is "Quick Add Next." This appears to be equivalent to Ctrl + B in Brackets, which is "Add next match to Selection" on the Find menu.
To quickly duplicate a line of code, place the cursor anywhere in the line and hit Cmd–Shift–D(Mac) or Ctrl–Shift–D (Windows).
Alt+F3 gives a really simple way to do find and replace: Use it to select all occurrences of the current word or selection, then just start typing to replace or edit them all at once.
In Sublime Text 3,when we press Ctrl+Shift+B, we are given the option to either do "Build and Run" or "only Build", whereas Ctrl+B executes the previously chosen operation among the two.
This seems to be a bug, or at least an unintuitive behaviour that only happens when the search bar is opened (after pressing ctrl+F, etc.) AND you selected a word part that is not already the string in the Find field (e.g. you searched for TOP before, and then you selected GRID).
The bug seems to be due to the specific behavior of find_under_expand
while searching. In search mode, it will fill the Find field with the whole word under the caret on the first call, then starts finding and adding more occurrences to the selection. But it has some inconsistencies. For instance, if you click on different words one after the other, pressing ctrl+D after each click, and it will always fill the Find field with the word, but will alternatively not highlight the word and highlight it.
When you select a sub-word, it gets worse and only the next sub-word gets highlighted the first time you press ctrl+D. The following times, you get a mix of fill Find field, cursor goes to end of word and extend selection (a behavior that made sense on a single and complete word) which results in the selection of the first two words, with the second word (GRID_SPACING
) filling the Find field.
Close the search bar with esc and then use ctrl+D / Find > Quick Add Next
repeatedly. Note that the selection won't be highlighted as searched strings (yellow in the default theme), but only as normal selection highlight (gray in the default theme).
If, after your first ctrl+D, you realized that your search bar was opened (and the Find field did not previously contain your target sub-word), it is not too late. Press ctrl+U / Edit > Undo Selection > Soft Undo
to go back to the original sub-word selected. From here, use ctrl+D repeatedly. With the Find field containing the target sub-word, selection will behave as expected.
Go to Preferences > Key Bindings - User
put following lines and save the file:
{ "keys": ["ctrl+d"], "command": "find_under_expand" },
{ "keys": ["ctrl+k"], "command": "find_under_expand_skip" },
{ "keys": ["ctrl+alt+d"], "command": "dpaste"}
It works for me. I've got installed DPaste package. That is why I had to overwrite its shortcut with the last line. Dpaste comes by default with ctrl+d
Hope it help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With