Sublime text 2, ctrl + d is not working properly

It seems that “quickly adding the next” and “expanding the selection into the word” are both mapped to the same key binding.

I am not sure how to override / change "expand selection to word" because I cannot find the current key binding for both actions.

Does anyone know what is caused by two actions?

To clarify, let's say I have the following code code

this.GRID_TOP = 10; this.GRID_SPACING = 10; this.GRID_HEIGHT = 10; this.GRID_WIDTH = 10; 

I want to select the "GRID" line in each line. I could use alt + F3 , but this is overkill. I want to select "GRID" and then press ctrl + D to select subsequent matches. My problem is that it works once (selects the first two), but then expands both cursors to the end of their words. Since the choices are different now, I cannot "quickly add the next".

+6
source share
2 answers

Error conditions and effect

This seems to be a mistake, or at least an intuitive behavior that occurs only when the search string is opened (after pressing ctrl + F , etc.) and you selected the part of the word that was not yet a string in the "Search" field (for example , you searched TOP before, and then you selected GRID).

It seems that the error is related to the specific find_under_expand behavior during the search. In search mode, he will fill in the “Search” field with the whole word under the carriage on the first call, and then start the search and add more cases for selection. But he has some inconsistencies. For example, if you click on different words one after another, pressing ctrl + D after each click, and it always fills the "Search" field with a word, but as an alternative does not select the word and select it.

When you select a subword, it gets worse, and only the first sublayer is highlighted the first time you press ctrl + D. The next time you get a combination of filling in the "Search" field, the cursor goes to the end of the word and expands the selection (behavior that makes sense on one and the complete word), which leads to the selection of the first two words, with the second word ( GRID_SPACING ), filling in the field search.

Bypass

Solution 1

Close the search bar with esc , and then use ctrl + D / Find > Quick Add Next several times. Please note that the selection will not be highlighted as the search string (yellow in the default theme), but only as the usual selection highlight (gray in the default theme).

Decision 2

If after your first ctrl + D you realized that your search bar is open (and the "Search" field did not previously contain the target subword), it's not too late. Press ctrl + U / Edit > Undo Selection > Soft Undo to return to the original subword. From here use ctrl + D several times. With the Search field containing the target subword, the selection will behave as expected.

+4
source

Go to Settings> Key Bindings - User

put the 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"} 

This works for me. I have the DPaste package installed. That's why I had to rewrite its label with the last line. Dpaste comes by default with ctrl + d

Hope this helps

+2
source

Source: https://habr.com/ru/post/946481/


All Articles