I have an issue when working in JS. If I have a string which i split into an array. For some reason when I start typing my variable followed by the first few letters of splice than there is no autocomplete for splice only split is displayed. See image bellow:
If I declare an array which I want to splice the splice autocomplete function is displayed. See image bellow:
Is there no way to always have the splice function visible in the autocomplete?
Related
I am trying to represent a basic vector, the following code works in Visual Studio Code.
I am using the following line $\begin{bmatrix}X\\Y\end{bmatrix}$
All whitespace removed. It should look like this,
However, when pushed to Github it does not render correctly and instead just renders to entire text letter for letter like it is unsupported. Does anybody know how to get get the following vector to display correctly?
Within my company we have an XML-based notation. Among other features, it is possible to define references from one XML document into another. I would like to enable autocompletion in Sublime so that whenever I am adding a reference, the possible files (i.e. XML files within the same project) and link points (i.e. symbols within that file) get offered as recommendations.
So far, I have found a lot of plugins that enable autocomplete for, say, HTML, PHP or LaTeX. However, I have the feeling the code base is too complex for a somewhat simple task. Is there, for instance, some vanilla function that generates completions based on an arbitrary array received as parameter? I would create the logic to determine what is a symbol and derive said array, but the whole process seems somewhat cumbersome to me.
(As a note: I can program in Python and have fiddled with other Sublime features, such as snippets, but these packages seem to be much more complex than it feels necessary.)
The base to create the completions entry is not to complicated. You now need to fill the array with the correct values (this could be done via a project setting or parsing other files).
import sublime
import sublime_plugin
# Your array, which contains the completions
arr = ["foo", "bar", "baz"]
class MyCompletionsListener(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
loc = locations[0]
# limit you completions scope
if not view.score_selector(loc, "text"):
return
completions = [(v + "\tYour Description", v) for v in arr]
return completions
OP's note: The answer works as advertised. However, the integration is so seamless that I thought for a while that something was missing. If the Python script above is on the right folder, all of the completions returned by the completions array will be suggested (depending on Sublime settings, it might be necessary to trigger the completions menu with Ctrl+Space). Also worth noting:
The completions may be None, in which case they just don't add any completion option, or an array of 2-tuples, where the first element is the description (which will be shown in the drop-down menu and trigger the completion) and the second is the value (i.e. the text that will be input if the completion is selected).
The score_selector method can be used to determine if the cursor position is within a given scope.
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
I have written a program that uses ncurses for the UI and the function mvwgetnstr to read in a string from a window. I want to allow users to make edits to the text they enter, so if they enter foo they can later go back and append bar. I cannot figure out how to do this with the curses API, the getnstr function only takes in a char buffer and length variable. Any ideas? I started making my own string input function, but it's difficult to keep everything constrained within the window.
It depends on what you want. There are many possible ways to organize a program:
getnstr reads the buffer from the standard screen (a window)
The wgetnstr function accepts a buffer from a given window. Using a separate window (or subwindow) reduces the problem of updates for the edited buffer interfering with other things on the screen.
getnstr editing is crude. If you use the form library (which in turn uses ncurses), that allows you to do more than just append/remove characters from the end of the input buffer.
write your own input-function, which can get complicated. The dialog program does this.
The ncurses-examples might be helpful for reading and seeing how to build up a suitable input function.
According to Oracle at JTextArea documentation, if you wish to wrap lines AND wrap at word boundaries and not character boundaries you must use code as follows:
jtaOutputPrimes.setLineWrap(true);
jtaOutputPrimes.setWrapStyleWord(true);
Please note that the jtaOutputPrimes is the name of my JTextArea on my JPanel.
The issue comes in when I use the method append to add text to the JTextArea as follows:
jtaOutputPrimes.append(",");
In this case, the setWrapStyleWord setting does not work. It continues to use the character boundaries and not the word boundaries.
I have found another person experiencing same issue here: setWrapStyleWord issue
Now, lets say you are running an JApplet that has this JTextArea. If you type in the text area, it will word wrap fine, but any passed text from the append method does not work.
I believe this is a bug, and I cannot find Oracle acknowledge it as such anywhere.
Can anyone help? Thanks!
I found out why this was happening, and this simple fix may be beneficial to others. The issue came into play because when I appended the comma (,) to the JTextArea it was eliminating the white space between words. To fix this, I simply placed a space after the comma like so, and it worked.
jtaOutputPrimes.append(", ");