Home Download Buy Blog Forum Support

Smarter Title Case

Smarter Title Case

Postby oregano on Mon Sep 03, 2012 5:53 pm

During my switchover from TextMate to ST2 I noticed a difference in the way Title Case is handled.

In TextMate, Text > Convert > To Titlecase changes:
this is an example of title case
to
This Is an Example of Title Case

In Sublime Text 2, Edit > Convert Case > Title Case changes:
this is an example of title case
to:
This Is An Example Of Title Case

This is an instance where TextMate yields better results. Per the Chicago Manual of Style, for example, the rule for titles all words to be capitalized except "articles (a, an, the), coordinating conjunctions (and, but, or, for, nor), and prepositions, regardless of length, are lowercased unless they are the first or last word of the title." (source)

My request is for ST2's title_case command to do this instead of indiscriminately capitalizing every word. A frequent scenario for us is when we're handed content with headings in ALL CAPS. Converting them is currently a 2-step operation in ST2 -- converting to Title Case, then editing the exceptions (above) by hand.

Thanks!
oregano
 
Posts: 1
Joined: Mon Sep 03, 2012 5:46 pm

Re: Smarter Title Case

Postby Shrikester on Thu Jan 17, 2013 9:18 am

I'd also love smarter case convert, so a vote from me as well!

In addition I would love something that Notepad++'s TextFX plugin has, which is called Proper Case (said plugin also has UPPER CASE, lower case, Sentence case and iNVERT cASE to a name few).

In Notepad++ TextFX > TextFX Characters > Proper Case changes:
this is an example of title case,
with multi-line conversion,
and some of the strangeness it creates.


to:
This Is An Example Of Title Case,
With Multi-Line Conversion,
And Some Of The Strangeness It Creates.


In Sublime Text 2, Edit > Convert Case > Title Case changes it to:
This Is An Example Of Title Case,
with Multi-line Conversion,
and Some Of The Strangeness It Creates.


Combination of smart case conversion and the way Notepad++ does Proper Case conversion would be ideal to me, seems like something the previous poster would also like.
BTW, I've no idea why the first letter of the second line (and after) is lower cased or where this would be a desired result, but that seems just wrong to me.
Shrikester
 
Posts: 4
Joined: Thu Jan 17, 2013 8:59 am

Re: Smarter Title Case

Postby Shrikester on Fri Jan 18, 2013 12:42 pm

Apparently this has already been added to the UserEcho as http://sublimetext.userecho.com/topic/1 ... itle-case/
Shrikester
 
Posts: 4
Joined: Thu Jan 17, 2013 8:59 am

Re: Smarter Title Case

Postby skuroda on Sat Jan 19, 2013 2:30 am

Though not built in, this is very doable through plugins. Though I didn't really test it much, I posted what I did on github (https://github.com/skuroda/ChangeCase). There is a command available to convert to title case through the command palatte ("ChangeCase: Title Case"). Ignored words can be found in the settings file.
skuroda
 
Posts: 690
Joined: Fri Oct 05, 2012 8:11 am

Re: Smarter Title Case

Postby Shrikester on Thu Jan 24, 2013 12:05 pm

skuroda wrote:Though I didn't really test it much, I posted what I did on github (https://github.com/skuroda/ChangeCase).

I was just looking into writing a plugin when I noticed this.
Tried to fiddle with it, but didn't get it to work at all. After installing (ZIP rename, copy into Installed Packages, restart ST2) the only thing I noticed was Package Settings in Preferences and it's empty submenus.

Tried to add it to Edit -> Convert Case submenu, but after looking into the code I wonder if this is supposed to change the way Title Case behaves instead of adding a new menuitem? It didn't change Title Case behaviour either tho.

None the less, thanks for looking into this.
Shrikester
 
Posts: 4
Joined: Thu Jan 17, 2013 8:59 am

Re: Smarter Title Case

Postby skuroda on Fri Jan 25, 2013 12:44 am

Shrikester wrote:
skuroda wrote:Though I didn't really test it much, I posted what I did on github (https://github.com/skuroda/ChangeCase).

I was just looking into writing a plugin when I noticed this.
Tried to fiddle with it, but didn't get it to work at all. After installing (ZIP rename, copy into Installed Packages, restart ST2) the only thing I noticed was Package Settings in Preferences and it's empty submenus.

Tried to add it to Edit -> Convert Case submenu, but after looking into the code I wonder if this is supposed to change the way Title Case behaves instead of adding a new menuitem? It didn't change Title Case behaviour either tho.

None the less, thanks for looking into this.


It doesn't modify the built in title case command. The command you want to specify is "change_case_title_case". I wasn't sure what would happen if I named it the same, and was lazy so didn't test it out. That being said, I did add a command to the command palette "ChangeCase: Title Case". In any case, I'd be happy to help you get it working if you would like. I'll try to check back here every so often, but it may be easier to create an issue on the github page since I will get notifications for those.
skuroda
 
Posts: 690
Joined: Fri Oct 05, 2012 8:11 am

Re: Smarter Title Case

Postby Shrikester on Fri Jan 25, 2013 8:16 am

skuroda wrote:In any case, I'd be happy to help you get it working if you would like. I'll try to check back here every so often, but it may be easier to create an issue on the github page since I will get notifications for those.

Sounds great, I'll use the github page and post you some information next week.

BTW, I'm on Linux (Ubuntu 12.04 64-bit) just FYI.
Shrikester
 
Posts: 4
Joined: Thu Jan 17, 2013 8:59 am

Re: Smarter Title Case

Postby bizoo on Fri Jan 25, 2013 9:12 am

skuroda wrote:The command you want to specify is "change_case_title_case". I wasn't sure what would happen if I named it the same, and was lazy so didn't test it out.

I can confirm it works, if you redefined an existing command, the last definition is used (at least for command that are defined in a python file in Default folder).
But take care that the packages are read in alphabetical order (Default is not read first and User last, like for settings and keybindings (bug ?)).
bizoo
 
Posts: 889
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Smarter Title Case

Postby Matt Stevens on Sat Feb 02, 2013 3:55 am

I was looking for something like this too and created a simple wrapper for Stuart Colville's Python implementation of John Gruber's Title Case script:

https://github.com/mattstevens/sublime-titlecase

Tweaked to add support for ST3 and available through Package Control as "Smart Title Case".
Matt Stevens
 
Posts: 2
Joined: Sat Nov 03, 2012 12:51 am


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 9 guests