Use method name for SublimeText 2 autocomplete as well as tab trigger - sublimetext2

The default SublimeText 2 snippets, located in the Packages directory and then under, say, Ruby are useful but only if you happen to know the tab trigger. For example the file ~/Library/Application Support/Sublime Text 2/Packages/Ruby/alias_method-..-(am).sublime-snippet contains:
<snippet>
<content><![CDATA[alias_method :${1:new_name}, :${0:old_name}]]></content>
<tabTrigger>am</tabTrigger>
<scope>source.ruby</scope>
<description>alias_method ..</description>
</snippet>
So we can access this trigger by hitting am then tab.
My question is, if this snippet chucks in alias_method :${1:new_name}, :${0:old_name} isn't there a way that I can use this snippet without knowing its am trigger, just by starting to type alias_m... for example?

Umm, no, not that I can find. I just opened up a blank Ruby file, hit a, and autocomplete popped up with all sorts of options, including the snippet you mentioned. However, if I then typed an l (starting to spell out alias...), the option for the am snippet disappeared. So, it looks like autocomplete is not searching the <description> field, only the <tabTrigger> field. There aren't any options in Preferences -> Settings - Default that would seem to address this situation.
So, unfortunately it would seem the solution is one of two things - either edit all your commonly-used snippets to have tabTriggers that make more sense to you, or put together a snippet cheat sheet. It looks like at least one other person was thinking the same thing, as I found this collection without too much searching.
Good luck!

Related

Disable code completion for a shortcut in PhpStorm

I stumbled across this, when I tried solving this: Searching for Live Template in PhpStorm, from abbreviation (wrong expansion?).
TL;DR
In PhpStorm, in a markdown-file, when I write 3 back-ticks and press enter, it expands to this:
```angular2html
```
And I would like PhpStorm to stop helping me here, and just type what I typed:
```
```
Detailed description and solution attempts
In a Markdown-file (readme.md), I use it often to write a code block with three ticks:
```
But when I do so, PhpStorm suggest a bunch of stuff:
So if I press Enter here, then it expands to:
```angular2html
```
So how do I change this behaviour?
Solution attempt 1: Deactivate the bundled Angular-plugin
There is a (bundled) plugin called: 'Angular and AngularJS'. If I deactivate that, then it looks like this:
and expands to this:
```apacheconf
```
Solution attempt 2: Ensure Markdown is supported
I'm really baffled why this happens. Does PhpStorm not realize that I'm in an .md-file?
And/or is this the usual desired behaviour, when people write three backticks in a and .md-file?
I can confirm that I have an active (bundled) plugin called: 'Markdown' (version 222.3739.61).
Solution attempt 3: Add a new Live Template
This actually works, by making a new Live Template, to be this:
```
$END$
Remember the blank line underneath. This is since I would like to press Enter, and that replaces the first 3 ticks with this, but not the ones PhpStorm automatically adds dues to auto-closing of brackets and backticks.
This solution attempt seems quite hacky, though. :-/
From https://youtrack.jetbrains.com/issue/IDEA-266239
The pop up was created to make specification of code fence language easier and to enable automatic code injection. We can’t disable it since it would affect a lot of users using it for fast code injection.
angular2html is the first entry in your case. Somebody else may have another language ID (e.g. aidl).
Right now it cannot be disabled or customized. So you will have to either use your own workaround (with Live Template) or press Esc before hitting Enter.
Other than that: watch that IDEA-266239 ticket (star/vote/comment) to get notified with any progress. No better suggestions right now.

Sublime text 2 Snippets - autocomplete

I've created a bunch of snippets in Sublime Text 2, but I cant remember them all off the top of my head. I've seen in a number of tutorials that as people start typing their snippets tab-triggers it will start to provide a list of the matching snippets. I don't see this.
Is there a setting somewhere for this? Or do I need to create a special file (completions file?). For most snippets I have the <scope> commented out as I may use in a PHP or HTML file for example depending what I am working on.
Most of my snippets tab triggers start the same elq- prefix, so it would be very helpful if it were to start showing me the options as I type.
The setting auto_complete_selector controls when Sublime automatically offers the popup for possible completions. The default value for this setting is:
// Controls what scopes auto complete will be triggered in
"auto_complete_selector": "source - comment",
This means that it will automatically pop up for any file that's considered a source code file, except within a comment.
The scopes for the file types that you mention in your question are text scopes and not source scopes, which stops the popup from appearing.
One way around that would be to manually invoke the auto complete panel by using the appropriate key binding, which by default is Alt+/ on Linux or Ctrl+Space on Windows/OSX. When you do that, the popup for possible completions at this point is manually displayed.
To allow this to work more automatically, you would need to modify the setting for auto_complete_selector to be more appropriate for your situation.
To do that you could select Preferences > Settings - User from the menu and add or modify the auto_complete_selector setting as follows:
"auto_complete_selector": "source - comment, text.html",
This says that the selector should always be displayed in source files except inside comments (like the default) and also within HTML files.
You could also use text instead of text.html if you want it to work in all text files of all types, although this would possibly get quite annoying while working with plain text files. Substitute an appropriate scope or set of scopes here as appropriate to dial in the places you want this to be automatically offered.

How to enable Code Completion Auto pop-up in WebStorm?

I've been trying to get Code Completion to work on the current version of WebStorm (2017.3), but to no avail.
Specifically when working with HTML code completion seems to only work when I press the shortcut ctrl+space. As far as I can tell I should be able to get the Code Completion look up table to pop-up automatically when I start typing by going to Preferences > Editor > General > Code Completion and checking the box for Autopopup code completion the thing is... I DON'T SEE THAT BOX!!!
This is driving me insane. I've looked under Code Completion in WebStorm 2017.3 Help and there are discrepancies between what the instructions say I should see, and what I actually see.
This is a picture of my Code Completion window in WebStorm 2017.3:
but it should look more like this (IntelliJ IDE 2017.3):
The Basic Completion box is missing in WebStorm. Not sure if that has something to do with it.
I've looked around and it seems like other people's Code Completion window looks like it's supposed to. For example in this Community Forum there is a post in 2015 and another in 2016 where the users show their Code Completion preferences and they look like they're supposed to.
I've tried re-installing WebStorm, deleting all preferences and the .plist but it hasn't worked.
I would like to note, that this issue seems to be affecting only my HTML documents, since the Autocomplete pop-up table for JavaScript works well.
Any ideas on what might be going on? Is there something on my end I can do to fix this?
In short: it works as intended.
Thing is: it's HTML context ... where everything is a plain text with HTML tags inside (despite the fact that whole HTML document starts with <html> tag and stuff).
In this regard HTML context is not that strict/obvious as JavaScript/PHP/etc is. There is no way to guess if you are trying to write a word strong or a HTML tag <strong> .. hence you see no completion popup when you just typing any word. But .. if you type < before starting typing strong it will be a hint for IDE that you are typing a HTML tag (which means HTML context)... and completion popup will appear as usual (no need to invoke it manually).
If it would work as you are expecting/proposing (having completion popup for each word) then I would see it for every word in Any ideas on what might be going on? sentence. It will be supper annoying to see that popup appearing/disappearing for no reason for each word (when I'm clearly typing a plain text). Some people get mad even for much smaller things (like highlighting a matching brace or tag when you move caret left/right)...
Related subject: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000719050-Autopopup-completion-works-inside-php-tag-but-doesn-t-work-outside-of-it-Is-there-any-fix-
If typing < is a problem (not convenient or any other "religious" reasons (e.g. "why should I type it -- IDE should do that for me" etc)) -- consider speed up even more with Emmet (IDE supports basic abbreviations as well as expanding sequences) or Live Templates (basic Emmet abbreviations are handled with Live Template under the hood anyway).
https://www.jetbrains.com/help/webstorm/emmet.html
https://www.jetbrains.com/help/webstorm/live-templates.html

Sublime Text set custom goto symbols

I am a big fan of ST2, and have been finding oodles of tricks to code/type faster.
One thing that I would like to know is if it is possible to create custom symbols for things like code blocks, include segments, and other bookmarks for goodies in your file.
For example:
I want to quickly include a standard C lib via (inc, tab). Is there a way for me to create a section where I keep all my standard lib includes (i.e: #CSTDLIB) and use the functionality of goto-> symbol (ctrl+r) to skip straight to this segment from anywhere in my file?
I tried looking to see if there was some sort of special handler to place in a comment that would recognise it as a "bookmark" but couldnt really find anything.
Cheers in advance.
This is an old question, so I'm answering for the latest ST3. Pretty sure this was possible with older versions as well.
The builtin C/C++ syntax definitions support a special formatting for comments in the following form:
// =jump target=
The string "jump target" will then be listed in the symbol list for ctrl+r. Unfortunately that only works if the // is at the beginning of the line. But we can fix that.
Install Package​Resource​Viewer, then from the command palette use PackageResourceViewer: Open Resource->C++->C.sublime-syntax.
In this file it says:
- match: ^// =(\s*.*?)\s*=\s*$\n?
scope: comment.line.banner.c
captures:
1: meta.toc-list.banner.line.c
Now remove the ^ in front of the regexp, save the file. Now you can enter comments // =jump target= anywhere, and jump there with ctrl+r.
If I have understood you correctly, you can use Ctrl + F2 shortcut for making bookmarks anywhere in your file, and walk through these bookmarks by F2 button. To remove bookmark, press Ctrl + F2 again in the line which you want to exclude from bookmarks.
If it isn't so, and this functionality doesn't cover your requirements, please specify more detailed use case.
Hope it will be useful to you

Format Code In MonoDevelop

I am using MonoDevelop on Mac to write MonoTouch apps. Automatica code indenting/formatting works great while I am typing.
The problem is that when I copy and paste code snippets, in many cases I lose the formatting and lines are combined together, indenting is lost, and it is a huge pain to implement the tabs, spacing, and line breaks manually. Is there anyway I can use a command in monoDevelop to automatically indent and apply the formatting to existing code.
I thought maybe Edit|Format|Format Document/Selection would work, but these commands don't have any affect on the code at all.
Any help?
To format the entire document in one keystroke: control-I
To format a selection: Edit->Format->Format Selection
To customize the formatting: MonoDevelop->Preferences->Source Code->Code Formatting
You actually need to select all your text, and then go to Edit->Format->Format Document. It doesn't seem to work otherwise.
For me on macOS, the shortcut for "auto-format" is CTRL + i.
You can change the shortcut if you want. To change it, go to Preferences -> Key Bindings, then type "format" in the search box and edit the "Format Document" shortcut/key binding.