'Expand selection to word' does not work as expected

Post Reply
dpd
Posts: 3
Joined: 09.04.2019 10:06

'Expand selection to word' does not work as expected

Post by dpd »

Hello,
I'm not sure it is a bug or just a limitation but let me explain the issue:

I have such a text file.

def labelLeft1 aa
def labelRight1 bb
def labelLeft2 aa
def labelRight2 bb
def labelLeft3 aa
def labelRight3 bb

I want to change 'def labelLeft1' and 'def labelLeft2' from 'aa' to 'cc' and leave 'def labelLeft3' unchanged. I select ' def labelLeft' in the first line and choose 'expand selection to word'. Nothing happens. CudaText claims 'cannot find 'def labelLeft'. The 'Highlight Occurences' pluging higlights properly all occurences of selected 'def labelLeft'.

In all other text editors I tried it with (sublime, vscode, atom, pycharm ide) this selection would work.

On the other hand I can select all 'labelLeft' instances in the text by:
1. select 'def labelLeft' in the first line
2. Ctrl+c
3. Ctrl+f
4. Ctrl+v
5. Alt+e
6. Esc
However it would allow only to modify all 'labelLeft' instances, not just first 2. By the way, it would be great to have some shortcut for selecting all instances instead of 6 step procedure. I tried macro, but didn't work. Is there any way to automate above 6 steps?
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Cmd "Expand selection to word" works like this: you select first "aa" and call this command. It selects next matches of "aa".
After selected n matches, just type "cc" to replace to "cc".
User avatar
kvichans
Posts: 203
Joined: 07.10.2012 05:45

Post by kvichans »

@dpd
Try plugin Macros to save a command sequence Ctrl+c, Ctrl+f, ... as one command
CudaText 1.163, TC9.51x32, Win10x64(1920x1080)
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

dpd
Posts: 3
Joined: 09.04.2019 10:06

Post by dpd »

Thank you for very prompt replies,

@Alexey
I know how 'exapnd selection to word' works in CudaText, but if my modify my example text like this it won't work anymore (i want to change aa and ab in this case to da and db):

def labelLeft1 aa
def labelRight1 ba
def labelLeft2 ab
def labelRight2 bb
def labelLeft3 ac
def labelRight3 bc


Regarding the macro, I tried but with no success. The problem is that macro records exact text selection I had in the clippoard while recording the macro, not the step of placing my curren clipboard content or even better selection, like below:

# Macro3
ed.cmd(cmds.cCommand_ClipboardCopy)
ed.cmd(cmds.cmd_FinderAction,'findsel\x01def labelLeft\x01\x01')

The last line should look more like this to work:
ed.cmd(cmds.cmd_FinderAction,'findsel(cmds.cCommand_ClipboardPaste)')
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

So "expand selection to word" cmd cannot help in this case.
You need to do Find, and enter some regex, and press [Select all] button.
dpd
Posts: 3
Joined: 09.04.2019 10:06

Post by dpd »

Alexey wrote:So "expand selection to word" cmd cannot help in this case.
You need to do Find, and enter some regex, and press [Select all] button.
Thanks Alexey. I quickly took a look at python api and it should make possible what I want. CudaText made really good impression on me so if I find some time I'll try what I can do.
Post Reply