CotEditor icon indicating copy to clipboard operation
CotEditor copied to clipboard

Automatically detect syntax style from shebang

Open nuno-agostinho opened this issue 4 years ago • 1 comments

When creating a new document, the first line could be inspected to look for a shebang like #!/usr/bin/env python3 or #!/usr/bin/ruby, allowing to automatically set the syntax style of the document.

This is especially useful to avoid setting the syntax style when pasting scripts to a new blank document.

nuno-agostinho avatar Apr 05 '21 14:04 nuno-agostinho

Hmm, interesting. The feature setting syntax style from shebang has already been implemented in CotEditor, but only when a file is opened (and there is no other clue in the filename), or when the document is firstly saved.

I feel I need to find the proper timing to detect the shebang. Maybe 1) the document is newly created, 2) the syntax style is not changed from the default, and 3) the first time a line break is input. In addition, I am now wondering if it worth to observe user's typing for such a rare case. Well, I'll consider. Thanks.

1024jp avatar Apr 06 '21 13:04 1024jp