How can I trigger a completion menu in a Sublime Text 2 snippet? - code-snippets

Can I trigger a code completion menu in a Sublime Text 2 snippet? I want a tab stop to display a completion menu with options instead of just highlighting the text.
For example, tabbing once in this snippet will highlight _link. Instead of just highlighting _link, it is possible to display a completion menu with other options like _selector, _content, and make a choice?
<snippet>
<content><![CDATA[it \{ should${1:_not} have${2:_link} \}]]></content>
<tabTrigger>it</tabTrigger>
<scope>source.ruby</scope>
<description>it { should_? have_? }</description>
</snippet>

Well, what you want is not really possible. However, you could set up a macro that would (1)insert a snippet and (2) activate autocomplete, but I don't think that's really what you want since you can't have custom options that way. You could also consider doing what the ZenCoding plugin does. The plugin will have a tabstop that like this: ${1:option1/option2/option3}. This will at least have the options displayed but they won't really allow for easy selecting and can get really busy fast. You're other option is just to have snippets for your common options and setting the scopes accordingly. For example, where it says <scope>...</scope>, you can specify a specify position where the snippet will apply instead of the just the default source.language. For more about scopes, I suggest you consult the docs here. Using this method might be the easiest and best way. That way in your snippet you could just trigger the autocomplete and the options will include your snippets. A few other options to look into could be creating a .sublime-completions file with a custom scope, or making something similar to Packages/HTML/html_completions.py.

Related

Is there any editor or popular editor extension that automatically remove quotes/brackets?

There are too many text editors, which have the function, that if I just select a piece of the code and press the quote/bracket key, the selected code becomes wrapped into the type of the quotes/brackets I pressed. But do you know any or are you using any, which has also the function, that if I select the piece of the code wrapped into the quotes/brackets and press the same quote/bracket key or some key combination, that piece of code becomes unwrapped?
Also if you know any editor or popular editor extension that automatically remove all quotes/brackets from the code, please write it too. Everything would be helpful.
We are doing some research and this question is still unanswered. Please help us if you know anything about.
I create a simple Zeus (Windows) Lua script that does this for the quote case (i.e. the macro wraps any marked area in quotes).
In a similar fashion another script could be written for the brackets case.
Also as this simple script shows, this should be possible in any scriptable editor.
The script can be found here: http://www.zeusedit.com/zforum/viewtopic.php?t=7148
SynWrite editor (Windows) can do scripting for u. You can write Python plugin in 10min, and assign it a hotkey, so selection (or all text) will dequote, or what ever.
Finally, I've made it by writing my own extension to my favourite editor.

Syntax completion based on snippets for rails project in vim

I wonder if exists some plugin which offers syntax completion based on rails snippets (from snipmate).
Example:
Being on specs, I provide shou, press hotkey and I got list of possible completions (like for Ctrl-p). Selecting anything from list, will insert a snippet.
Does something like this exists?
You can hit <C-r><Tab> in insert mode to pop up a list of available snippets, hit <Enter> to select the right one and hit <Tab> to expand the snippet. But the menu doesn't provide a description.
This is not specific to SnipMate, but you might also find Vim's line completion feature useful here. While in insert mode, Ctl-xCtl-l will offer possible completions for the whole line. So if you already have something like the following in your open buffers:
it { should belong_to(:user) }
it { should validate_presence_of(:title) }
and you start typing
it {Ctl-xCtl-l
... you will get a list of possible full line completions to match.

How I can add some items to the code completion combobox of the Delphi IDE

I'm working in a Delphi IDE expert and I wonder if it's possible add new items to the code completion combobox displayed by the Delphi IDE when the user press CtrlSpace
UPDATE:
What I need is add items to the code completion list based in a specified type.
example suppose which I have a type called TMytype, what I want to do is add addional items to the code completion list when the user type a variable of the type TMytype
check this image
I found your question somewhat confusing but if you are in search of credible source on "Custom Live Templates" and the like on Delphi, head to the blog of Cary Jensen here.
Edit:
Looking forward to further improvement of the scope of the question, I suggest here another direction to explore:
Source code manipulation using IOTAEditor, IOTASourceEditor, IOTAEditReader and the like
Some Parsing for sanity check prior to apply any modification.
Adoption of Client DataSet as a format to store data (It's serializable) to simplify the coding of IDE editors.
Perhaps I haven't fully grasped the extent of what you are asking here, but you can add templates simply by going to 'View|Templates' from the Delphi IDE. This then opens a template viewer. Press the '+' icon. It opens a template1.xml document which you can then edit so create your new item.
If you wish to do this programatically, just add an xml file (of the same format) to the ..\RAD Studio\code_templates folder.

Textmate editing 2 words at same time

I am not 100% sure if this is the right place to be posting this question, but I could not think of anywhere else.
I having been using textmate for around 6 months to write Ruby on Rails applications.
The snippets and stuff are nice. I am wondering if it is possible to edit to words at the same time. I am using the mcol snippet which generates a add_column and remove_column in a database migration.
When the code is generated it highlights the table_name and changes both occurences of the word table_name when you start typing.
Hoping that this can be done to any word that you select.
Cheers
Eef
Since the whole idea of TextMate is to have an editable editor(!), if you look at the HTML bundle, the shortcut ctrl-shift-w invokes this:
<${1:p}>$TM_SELECTED_TEXT</${1/\s.*//}>
So, to add a custom shortcut to wrap a selection in a pair of editable text strings (which is what you want, I think?), go to Bundles > Show Bundle Editor then choose New Snippet from the add + button (bottom left) and use (e.g.):
${1:editme}$TM_SELECTED_TEXT${1/\s.*//}
where 'editme' is the default 'doubly-editable' value. If you add a new snippet shortcut in the 'Key Equivalent' field (I used ctrl-shift-alt-W) you can then wrap any selection in an editable pair of words. Depending on what you need, the same syntax might be expanded to match your requirements?
Note: once the shortcut is allocated, you can't edit a snippet in place - you need to start again (I think - couldn't find a way around that).

Latex Beamer: How is it possible to make piece of text in a frame in italics?

I am using Beamer in order to make a presentation. In one of the frames I want to write something like this:
"Italics is like that"
I used a command \it of Beamer for doing this:
\it{Italics} is like that
But as a result I get:
"Italics is like that"
Is it possible to make italics only a piece of text?
I believe you're looking for \textit{}.
Also, in the future, consider asking LaTeX questions on the TeX - LaTeX Stack Exchange site.
\it is a switch, it changes the font series starting from the point it was issued till the end of the current block. Therefore you have to enclose the block of text it should affect:
{\it Italics} is like that
Alternatively you can use \textit as suggested by gotgenes which only affects the text passed to the command within braces:
\textit{Italics} is like that.
What about \emph{text} ?

Resources