how to write a snippet than can toggle text like snippet Get Element - sublimetext3

In snippet Get Element, when i type get and push tab, it will show
getElementsByTagName('')
and the letter T is highlight and editable, then typed letter I, it will change to
getElementById('')
automatically.
I want to create a snippet which can toggle text by the letter i typed, just like the snippet Get Element do, but i can't find where the snippet location.
Anyone know its location or know how to create a snippet like that?

The snippet is inside the archived JavaScript package, which is located in the installation directory, and then Packages/JavaScript.sublime-package. Inside that package, the file's name is Snippets/Get-Elements.sublime-snippet and it has the following contents:
<snippet>
<content><![CDATA[getElement${1/(T)|.*/(?1:s)/}By${1:T}${1/(T)|(I)|.*/(?1:agName)(?2:d)/}('$2')]]></content>
<tabTrigger>get</tabTrigger>
<scope>source.js</scope>
<description>Get Elements</description>
</snippet>
Basically, it works with conditional replace format strings. You can find the documentation for those in the boost regex docs, however I suggest to just have two different snippets in this situation with the triggers gett and geti respectively, since those still require the same number of key strokes but are way easier to create and maintain.
You can open archived resource files like this easily with the PackageResourceViewer package.
Details on what archived packages are: http://docs.sublimetext.info/en/latest/extensibility/packages.html

Related

Can sublime 3.0 convert display from plain text to source color scheme automatically?

I'm little new to Sublime, wanted to know if there is a way to change display in sublime-3.0 from plain text to source colors automatically (i.e. Sublime should keep source colring from where code was copied and pasted like- HTML or XML or Java code) without I changing it manually.
Thanks in Advance!
Sublime Text already does this for some languages, like XML.
It works when you have a blank document that is set to Plain Text format (i.e. you open a new tab), and paste something in whose first line can be identified to be a specific language, using regular expressions.
For XML, it looks for an XML prolog or an XML element with a namespace. Regex
For HTML, it looks for a HTML doctype.
It currently doesn't support Java - I guess it's not easy to come up with a regex that would match only the first line of a Java file and not a C# file, for example. If you do have some ideas, you can use https://packagecontrol.io/packages/PackageResourceViewer to edit the relevant .sublime-syntax (YAML) file and add a first_line_match in.
You may also find the following packages helpful:
https://packagecontrol.io/packages/AutoSetSyntax
https://packagecontrol.io/packages/ApplySyntax
Extra note: these "first line matches" also apply when opening files that aren't automatically matched to a syntax by the file's name/extension.
There might be a better way, but I've done it with the Package control ctrl+shift+p (Win, Linux) or cmd+shift+p (OS X). Search for Package Control: install Package, press Enter and then search whatever package you need.
After installing the SCSS package, I'd get the HTML colouring as well.

Change SublimeREPL shell colour

I use SublimeText3 and try to change the colour for SublimeREPL Shell because its all white. Is that possible? Or is it possible to use colours from system prompt like PS1='' ?. I am running on ubuntu. I haven't found a soloution.
I assume you're trying to color the prompt in the SublimeREPL shell - if you want syntax highlighting of the commands you type, just change the syntax to Shell Script (Bash). To do this permanently, open your Packages folder (Preferences -> Browse Packages...), browse to SublimeREPL/config/Shell, and open Main.sublime-menu as a JSON file. Line 26 contains the "syntax" setting; just change the value to "Packages/ShellScript/Shell-Unix-Generic.tmLanguage", save the file, and the next time you start it the syntax will be applied.
However, if you're just trying to color the prompt, you'll have much more work to do. First, you'll have to create a custom .tmLanguage syntax definition file creating scopes for the various parts of the prompt you want to highlight, then you'll need to alter your color scheme's .tmTheme file to actually style the scopes. (If you're using the ST3 dev builds and have Build 3084 or newer, you can also use the new YAML-based .sublime-syntax format instead of the XML-based .tmLanguage one.)
If you're not using a dev build, the best way to write syntax definitions is to use the wonderful PackageDev package. I maintain an alternate - and better :) - syntax definition for Python and I much prefer using PackageDev's .YAML-tmLanguage format, which as you can tell is also based on YAML, but was around long before the new "official" .sublime-syntax format, and of course they're incompatible. However, it is quite easy to convert from YAML-tmL to tmL to sub-syn and back again, so it's no big deal.
However, as I was saying, the contents of your syntax definition will vary depending on the exact structure of your prompt, and what you want to do with it. For the following examples, I'm assuming you have the default Ubuntu user#hostname:/present/working/directory$ prompt. To create a new syntax definition, after installing PackageDev, select Tools -> Packages -> Package Development -> New Syntax Definition and you'll get the following:
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: Syntax Name
scopeName: source.syntax_name
fileTypes: []
uuid: 7e1549b3-fb0b-44fc-a153-78a7fc2157c2
patterns:
-
...
The first line is required, don't mess with it. You can make name whatever you want. scopeName is obviously the identifier for the base scope, perhaps something like source.shell.prompt. fileTypes can be left blank, and the uuid left alone as well.
If you want to get a feel for how these files are supposed to work, feel free to check out PythonImproved.YAML-tmLanguage on Github, and also make use of the Sublime Text Unofficial Documentation page on the subject as well as the reference. There's also some info in PackageDev's README.
I'll let you develop the rest of the regexes, but here's one for matching the username to get you started:
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: Shell Prompt
scopeName: source.shell.prompt
fileTypes: []
uuid: 7e1549b3-fb0b-44fc-a153-78a7fc2157c2
patterns:
- name: meta.username.prompt
match: ^([A-Za-z_][A-Za-z0-9_-]{0,31})(?=#)
...
You can see it working here.
Once your .YAML-tmLanguage is complete, save the file, open the command palette, and select PackageDev: Convert (YAML, JSON, PList) to.... This will build the .tmLanguage file and put it in the same directory as the .YAML-tmLanguage file. If it's not already under the Packages directory tree, copy it to your Packages/User directory, then modify the Main.sublime-menu file as described in the first paragraph. Finally, open your color scheme's .tmTheme file and edit it to add the scopes defined in your new syntax. Save it, restart Sublime for good measure, and you should be all set!

sublime 3 inactive selection tag

I am in middle of modifying Monaki theme, I want to change color of inactive select. when I double click something sublime automatically highlight other occurrence of the word in the document.
I am aware of caret but caret is just the border, what i want to achieve is to change the background of caret.
I searched a lot but couldn't find any documentation to list these tags and valid input for them.
I also tried inactiveSelection but had no luck with it.
so I have two questions.
first, how can I achieve this and change the color of the auto select?
second, is there any documentation out there that I can read about all the valid key/strings.
for example, in code bellow
<key>bracketContentsForeground</key>
<string>#16F24D</string>
<key>bracketContentsOptions</key>
<string>foreground underline</string>
how can I know <key>bracketBackground</key> is a valid code or what about <key>bracket</key> ? or <string>foreground underline</string> is there any other value that i can put inside the <string>? I see many ppl modifying the themes, but i can't find the source that they are learning from. I don't mind if I need to read inside the code to see what is the available tag, but I don't know to read which file.
selection key and inactiveSelection key
e.g., for monokai.tmTheme
selection string try #343400
inactiveSelection try #341700

notepad++ how to convert to typing assistant like?

I was using notepad++ to create a report and its taking a quite a while for me to type and do so.
Well i had tried a software called typing assistant it was really good(except for the money part :D).
TO the Point :
is there any way tat i can link a dict(text file of words) and use notepad ++ as typing assistant please tell me if so i
can speed my report.
Cause i am a programmer too so i really like the keyword completion and stuff .But is there a way to use it for text ?
already tried Phrase Express -.-:
Takes long and its kinda for macro text and text completion don't work tat fast for me to tab and complete
if there's a question in the form like mine link me to tat :
i searched it and i didn't get it
Yes, you can set up your own custom auto-complete dictionaries in notepad++. You need to create an xml file with your language name and put it under the plugins/APIs directory in notepad++. Of course this assumes you know how to write xml. There's a formal description of how to implement this here.
I've never tried to create an auto-complete dictionary for plain text files, so I'm not sure if it's possible, but I have successfully created them for user-defined languages, which you could also do if you can't get it to work with text files.
I'm not sure if this question is really a duplicate, but here is a very similar one, which may help you in your research.

TYPO3: indexed_search and title tag

Is there a way to get a title tag in the search results of indexed_search?
Instead of
Text
there should be
Text
Not a real solution but best I could do:
I think this won't be possible without changing the extension's PHP code. If you do so, copy the extension folder from the systext folder to your typo3conf/ext folder, otherwise you will get in trouble when updating Typo3.
indexed_search seems to have only hardcoded -Tags. You can check this by looking first at the actual HTML output (your search results). Then compare this with the HTML template used. If you have shell access to your server, a grep command might help to locate the correct template. Then try to find the marker. I suppose in your case it's ###TITLE###. Then you have to figure out how the marker is filled. Again a grep command for '###TITLE###' in the folder's extension might help you. Then you will see if the tag is hardcoded or not and how you can change it.
Often the faster solution is to use the template object browser and to try to find a piece of TypoScript below plugin.indexed_search which could be responsible what you want to change.
Unfortunately in your case both didn't help. For some strange reason, '###TITLE###' isn't contained anywhere in the the indexed_search extension.
A very ugly workaround would be to use javascript or jquery to insert the attribute.

Resources