Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use javascript in “find” field #20

Closed
Haale opened this issue Jul 26, 2023 · 2 comments
Closed

use javascript in “find” field #20

Haale opened this issue Jul 26, 2023 · 2 comments

Comments

@Haale
Copy link

Haale commented Jul 26, 2023

Is it possible to use javascript in "find" filed?
For example, read a regular expression string from a text file and convert the raw string to the format string (like transforming backslash into double backslash,double quote into backslash+double quote) that javascript accepts.

Or have the "Find and Transform" supported that feature already?

@ArturoDent
Copy link
Owner

How do you want to use this exactly? In general, you can not use javascript to create a find query from code selected in a file (although that is an interesting idea), but you can use regex's in text as find queries. If you have no find in your keybinding/setting, this extension will use any selections in the file as the find queries.

If you have text like someText\d+.ext\d

and select it, then text like this will match and be selected and replaced if you have a replace field:

someText1.ext0
someText222.ext1
someText3333.ext2
{
  "key": "alt+e",
  "command": "findInCurrentFile",
  "args": {
    "isRegex": true,             // MUST have this for the selection(s) to be treated as a regex
    // "replace": "some replacement"
  }
},

You can even select 2 or more regex's in the file and have them all select any matches:

regexFromText

Is there something else you wanted to do not covered by the above?

@Haale
Copy link
Author

Haale commented Aug 1, 2023

How do you want to use this exactly? In general, you can not use javascript to create a find query from code selected in a file (although that is an interesting idea), but you can use regex's in text as find queries. If you have no find in your keybinding/setting, this extension will use any selections in the file as the find queries.

If you have text like someText\d+.ext\d

and select it, then text like this will match and be selected and replaced if you have a replace field:

someText1.ext0
someText222.ext1
someText3333.ext2
{
  "key": "alt+e",
  "command": "findInCurrentFile",
  "args": {
    "isRegex": true,             // MUST have this for the selection(s) to be treated as a regex
    // "replace": "some replacement"
  }
},

You can even select 2 or more regex's in the file and have them all select any matches:

regexFromText

Is there something else you wanted to do not covered by the above?

Noted

@Haale Haale closed this as completed Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants