Home Download Buy Blog Forum Support

A bunch of general questions

A bunch of general questions

Postby chlab on Wed Jul 17, 2013 9:04 am

Hi folks

I switched to Sublime 2 about a week ago after years of using BBEdit. I'm really enjoying the simplicity, the speed and the powerful features and plugins.
I've customized a lot, gotten used to certain things, but some questions remain. If you can answer any of them, I would be very happy :).

1. Auto completion
When typing something like $(' sublime automatically appends ') after the cursor, which is great. After I type my selector $('.my_selector|') (I marked where the cursor is red) - I still have to type either ') or super+→ to get the end of the line and continue writing, which kind of defies the point of autocompleting that statement in the first place (since I have to type it out anyway to keep going).
I would expect hitting tab to take me to the end of the line, but that doesn't work. Is there some shortcut to do this (get to the end of the line in this situation)?

2. Auto indentation
I like the auto-indentation, but it doesn't play nice with our company's coding conventions.
Example:
Code: Select all
function foo()
  {
  do_something();

  var o = {
    something: 'else',
    b: true
    };
  }


Writing something like this is problematic with Sublime Text:
Code: Select all
function foo()
  {
    | <- this is where cursor is placed by auto indentation
| <- clicking an empty line within the function places the cursor here
  | <- but this is where I would like it in both cases
  }


Is it possible to customize this more granularly? I do not want to disable auto indentation alltogether. But this requires me to hit backspace everytime I write a new function or object. This is really bugging me, any help would be greatly appreciated. Even if I have to go hack the code somewhere to achieve this. I think an option like tab_size_within_structures: 0 is what I'm looking for.

3. Expand selection to scope
The shortcut super+shift+space is very handy. I would like it more if it would select the contents of quotes without the quotes though. So in this string 'this is a string' it would select the whole string with the quotes, instead of just this is a string. Is this possible?

4. Map file endings to syntax
In some cases, you want different syntax highlighting than Sublime automatically chooses. In BBEdit, you could map file endings to syntaxes globally, and if you changed it manually within a project, that setting was saved for the project workspace. For example I usually want JavaScript highlighting for .json files (instead of the default JSON highlighting). Is their any way to map this? Wouldn't it make sense to store manual overrides in the project workspace?

5. Syntax highlighting
For some reason, in PHP files, keywords are also highlighted within docblocks and some quotes. Example:
/**
* @param string Foo
*/

@param is in a comment block so it shouldn't be highlighted imho. Can I change this somehow? In large PHP files it gets distracting when the comments are all highlighted up.

6. Code completion
Is it possible to write custom code completion files? I would love to extend e.g. the JavaScript code completion with the standard JS functions (e.g. getElementById()) or the jQuery methods. So if I type $.add, Sublime would suggest addClass to the list of names it suggests.

Thanks for any help on any of these issues!
Chris
chlab
 
Posts: 6
Joined: Wed Jul 17, 2013 8:19 am

Re: A bunch of general questions

Postby qgates on Wed Jul 17, 2013 5:19 pm

Chris,

1. What you ask for isn't supported "out of the box" but can be fairly easily achieved with a macro and keybinding. For example, I created something similar for HTML so that, when using Emmet/Zen coding, I could skip past closing tags intelligently.

2. What you want is whitesmith indentation. If you search around the forum, others have asked for this but so far Jon hasn't implemented it. I'm not sure whether Sublime's indentation system can be easily extended to support it through a plugin, perhaps someone else can chime in.

3. You're question is a little contradictory. However, ctrl+shift+space should do what you want in either case. On my system, the shortcut is expansive upon each additional press. Ie. the first press selects the content without quotes, the second press with quotes, the third press selects everything between the containing {} (in php), the fourth press includes the {}, etc. etc.. If you don't see that behaviour perhaps a plugin is overriding it.

4. http://stackoverflow.com/questions/8088 ... -sublime-2
nb. this sets up the syntax to file extension globally. Not sure if this can be overridden per-project, perhaps someone else can chime in?
nb2. to do a one-off, non-sticky syntax change for a file ctrl+shift+p ss <type> <return> is superquick anyways :)

5. This behaviour is by design. Sublime intelligently hilites docblock keywords in docblock sections. If you remove one * from the opening comment, you'll see the hiliting disappear, as it's no longer considered a docblock.

6. This should help: http://docs.sublimetext.info/en/latest/ ... tions.html

:)
qgates
 
Posts: 230
Joined: Mon Nov 05, 2012 4:33 pm

Re: A bunch of general questions

Postby rob49152 on Thu Jul 18, 2013 12:14 am

For the docblock you can add this to your .tmTheme file (make sure to add this before the </array> in the file)
Code: Select all
<dict>
  <key>name</key>
  <string>PHP String</string>
  <key>scope</key>
  <string>keyword.other.phpdoc.php</string>
  <key>settings</key>
  <dict>
     <key>foreground</key>
     <string>#666666</string>
  </dict>
</dict>

and of course substitute the hex colour code to whatever you want.
rob49152
 
Posts: 14
Joined: Sat Jun 15, 2013 10:02 pm

Re: A bunch of general questions

Postby chlab on Tue Jul 23, 2013 9:49 am

Hi
Sorry for my late reply, I was away for a few days.

qgates:
Thanks for your detailed response!
1. Would you share your HTML macro to help me get started?
2. Thanks. Bad news I guess. I hope there's some way to achieve this.
3. For me, the first time I press super+shift+space it selects the whole string with quotes right away. Is this the key binding you have for ctrl+shift+space?
Code: Select all
{ "keys": ["super+shift+space"], "command": "expand_selection", "args": {"to": "scope"} }

4. Thanks, that worked (at least globally)!
5. rob solved that one
6. Thanks. I'd have thought there would be tons of completion sets for projects like jQuery, but I can't seem to find one. I guess I'll write one myself sometime soon.

rob49152:
That works. Aweomse, thanks!
chlab
 
Posts: 6
Joined: Wed Jul 17, 2013 8:19 am


Return to General Discussion

Who is online

Users browsing this forum: Yahoo [Bot] and 25 guests