Alexey-T / CudaText

Cross-platform text editor, written in Free Pascal
Mozilla Public License 2.0
2.54k stars 174 forks source link

auto-pairing quotation marks and brackets #5196

Closed George1825 closed 1 year ago

George1825 commented 1 year ago

For ( or “,is there a function to automaticly to the flowings( which I used to use in Spyder IDE): 1.When typing ( or “ ,auto typing the pairs ( ) and put the caret in the middle。 2.When select some content and typing (, auto add pairs ( ) to the selected contents rather than replace it. Is there already some features like this? Thanks!

Alexey-T commented 1 year ago

Yes, Cud has such an option. Option is called with word “bracket” AFAIR. Open the “default config” and search in it.

George1825 commented 1 year ago

Yes, Cud has such an option. Option is called with word “bracket” AFAIR. Open the “default config” and search in it.

Get it!For " or ', can we do same thing?

Alexey-T commented 1 year ago

yes, option supports quote chars too. default.json tells:

Auto-pair some chars on typing.
Value must have some of supported chars without spaces:
  ( [ { < ' " ` ~ * #
(Don't forget that JSON file needs "-char in escaped form.)
George1825 commented 1 year ago

yes, option supports quote chars too. default.json tells:

Auto-pair some chars on typing.
Value must have some of supported chars without spaces:
  ( [ { < ' " ` ~ * #
(Don't forget that JSON file needs "-char in escaped form.)

Sorry, I didn't really get how to use escape character in json. That's also what I met when try to add quotation marks in extension selection plugin. I've tried several ways, but didn't work: //(Don't forget that JSON file needs "-char in escaped form.) Original: "auto_close_brackets": "([{", Option 1: "auto_close_brackets": "([{/'/"", Option 2: "auto_close_brackets": "([{-'-"", Option 2: "auto_close_brackets": "([{"'""",

Alexey-T commented 1 year ago

Char \ must be used as escape char.

"auto_close_brackets": "([{'\"",

"-char needs to be escaped. '-char not.

George1825 commented 1 year ago

Char \ must be used as escape char.

"auto_close_brackets": "([{'\"",

"-char needs to be escaped. '-char not.

Thanks,now for brakets and ‘,it works. For “, it still doesn't work. Could you please try it again?

Alexey-T commented 1 year ago

For “, it still doesn't work.

The " char is different than “. For me it works for " char if I have

  "auto_close_brackets": "([{'\"",

and if I type "-char in the new line (no nearest word chars).

George1825 commented 1 year ago

Maybe I figure it out. I already set the "auto_close_brackets": "([{'\"", in user.json and it works now. Maybe default.json is overwriten by user.json.

Alexey-T commented 1 year ago

You should NOT write value to default.json. https://wiki.freepascal.org/CudaText#Configs

George1825 commented 1 year ago

Get it, many thanks!