Add a cursor to each selected block in sublime? - sublimetext2

I have the letter p on multiple lines, so when I double click it it selects all the the stand-alone p's. It doesn't select the p's inside other words, exactly how I want it to be. Now, what is the shortcut to add the cursor to each of those selected blocks? I've been surfing the web for a solid 30 minutes trying to find one simple shortcut and it's quite frustrating because I feel like I used to know this too, but no one has it listed.
Using CtrlD doesn't work because it simply finds the next letter p, which happens to be inside many words I don't want to edit. Also I can't use CtrlShiftG because p is only one letter and there is no word for the cursor to be inside of. :( Please help!
Using ubuntu, if it matters.

If you select the space before and after the p, then hit AltF3 (Quick Find All) then you'll get what you're looking for.

I am not sure I understand your question correctly, but what I think is you want to select all the P's in a specific block of text.
If that, just select the text, press Ctrl-F, type p, and click Find all. It will select all the P's in the selection.

Related

Align text within drop down list option elements

I have an html page with an option list where the user will choose to display information related to an event. As such, I want each option in the drop down list to show a date and X happened to Y. Within the option list, I'd like to have the dates left-aligned, then the "X's" aligned among the different options, then the "Y's" aligned with each other (I believe it will make it easier for people to see the differences when scanning the list).
Basically (as best as I can render here), this is what I'd like to do:
1/1/2000 This thing shipped to Anywhere, KS
12/18/2003 The other thing installed at Nowhere, NV
3/22/2007 The darned thing failed in Roswell, NM
^ 2nd block aligned ^ 3rd block aligned
I've tried div's within the option entries, but that made no difference.
I have searched exhaustively for something along these lines, but I haven't found anything even close (only questions on how to center align the entire option text, etc.). Is something like this even possible?
A select is not way to do this if you want formatting like that. HTML is not allowed in an option tag. According to the MDN, permitted content of an option tag is:
Text with eventually escaped characters (like é).
If you want to keep the "look" you'll need to find a different approach, like a table with a radio button in the first column of each row.

Any way to make double click select more than one word without Javascript?

Let's say I have a web page which contains command line commands for the user to copy paste. Any way to display it with HTML/CSS which makes double clicking on one word select the entire command?
Example: ls -l /myfiles - clicking on "myfiles" here selects only that word, but for the user it'd be a better experience if the entire command was selected for easier copy-pasting. Again: No javascript is the question here.
I commented in the question that selecting multiple words by double clicking is not possible without javascript. This is not totally true at least for firefox. I just found a way that will select multiple words by double clicking the first word!
You need to use a space followed by unicode ‏ (right-to-left mark)
Only works in Firefox!
jsfiddle demo
OR double click 'Hello' in the block qoute for demo.
Hello ‏my ‏name ‏is ‏Kasper
I don't know why this is working. I was just experimenting with unicodes... More info can be found on w3.org:
Using a Unicode right-to-left mark (RLM) or left-to-right mark (LRM) to mix text direction inline
EDIT:
Using other unicode space characters may be closer to the behaviour you want. For example unicode   DEMO (jsfiddle) OR double click any word in the block quote below (again, only works in firefox)
Hello my name is Kasper
other example (double click on a word with capitals)
in this SENTENCE ONLY WORDS WITH capitals are
selected
Would they be able to just triple click? You can select an entire element with that, or to limit it put in breaks.
This would keep expected highlighting behavior consistent.
No there isn't any way to do that for a double click without javascript.
The default browser behavior is the only behavior available without javascript.
Tripple-click will works to select a single line.
If you want to select a different pattern, you need javascript.
If you only want this behavior on double-click, you need javascript.
Setting the CSS property user-select: all; would allow to select the whole element using a single click: https://www.w3schools.com/cssref/css3_pr_user-select.asp

Close tags dropping below highlighted line

I have minimal experience with HTML script so this may all go horribly wrong here.
Alright so I have a very simple yet very time consuming task of taking complete papers and converting them into HTML script. I'm using Sublime Text 3 with Emmet plugin.
Basically,
This is the first header
This is the first paragraph that needs to be tagged
This is the second header
This is the second paragraph that needs to be tagged
So super simple I need to put header tags on the headers and paragraph tags on the paragraphs.
What I have been doing is holding Ctrl and manually highlighting the desired text as it is all rather random. Problem is that takes forever to manually highlight the text like that.
I am aware of other ways to highlight such as Ctrl + L for the line. Problem is my close tags end up under the highlighted line.
Example:
<h2>This is the first header
</h2><p>This is the first paragraph that needs to be tagged
</p>
It's not a big deal but it makes the code harder to go through later and really chaotic.
The same problem persists if I click the corresponding number of the line.
Seeing as I have hundreds of pages to enter and even more headers, paragraphs, and pictures to properly tag; I'm looking for a solution to the tag dropping below the line or a faster method to entering text.
So, is there a fast method for entering text from a word document to Sublime text and quickly get the corresponding tags? e.g. <h2>,<h3>,<p>,<ul>,<li> and so on.
Any help will save my sanity, thanks.
When you select a line with CtrlL, it automatically selects the entire line, and moves the cursor down to the first position on the following line. There are two ways around this. The first is to place the cursor in the first position on the line you want to select, then just hit ShiftEnd and the line will be selected, with the cursor now sitting in the last position on that same line. Alternatively, use CtrlL, then hit Shift← (left arrow) to move the cursor from the first position on the next line to the last position on the selected line. Either way, you can now hit the key combo in Emmet for inserting a tag pair, and you're all set.

Looking for an addon to automatically select all instances of selected word in the current page

I am looking for an addon to install so that when you select a word in a webpage ( by clicking) it automatically highlights all the instances of that selected words in that text. There used to be this
highlightall addon but it no longer works for recent version of Firefox! It was ver handy as all you had to do is to select that word and all instances get highlighted
Such an addon would be very helpful when reading a code as you can simply select a variable name and it would select everywhere that variable has been used in the code so you could understand the program better.
Ok man I made the addon and released it at AMO. I called HiliteOnSelection I linkified it.
Use it tell me how it works tell me how you would like to change it etc. I appreciate feedback.
More than 50 bounty would have been nice too, a side effect was I learned a lot so it's cool.
If you press ctrl+f and then click highlight all it will do it.
If you want to copy it heres the code for highlihgt all:
function toggleHighlight(aHighlight) {
if (!this._dispatchFindEvent("highlightallchange"))
return;
let word = this._findField.value;
// Bug 429723. Don't attempt to highlight ""
if (aHighlight && !word)
return;
this.browser._lastSearchHighlight = aHighlight;
this.browser.finder.highlight(aHighlight, word);
}
here it is on mxr
if you need more help let me know
Well, my code is quite complex because it performs several advanced services, but if you're asking how to highlight a word of text, the easiest way is to add a style attribute around the word. For example:
This hot dog needs more mustard.
... would become...
This hot <span style="color:#FFFF60">dog</span> needs more mustard.
The above would highlight "dog" in the sentence. The above assumes white text on black background, where yellow is a good highlight color. If the text is black on white background, that #FFFF60 should probably be something like #40FFC0 or #40FF40 or #4040FF or whatever you find looks good.
When you want to remove the highlight, you can delete the <span> element. In my case I usually put the style="color:#FFFF60" in some other existing element, so I don't delete the element to remove the highlight, I delete the style attribute I added to the element.
By the way, the reason I change text color to highlight terms is because that does not change the size of the word, and therefore the text never reflows (and screws up formatting). You could probably change background color to highlight, but I never tried that.
To find all instances of a certain word, I don't know, but probably the TreeWalker is part of the solution.
Ok C Graphics man here's the code
Ok its real easy you don't even have to write another function. Here's the code to highlight any word in the current tab.
gBrowser.selectedTab.linkedBrowser.finder.highlight(true, 'YOUR_WORD_HERE')
if you want to unighlight then set the first argument to false.
You can do this in any tab just have to supply the browser element within the tab.
like this code here will highlight everything in the first tab:
gBrowser.tabContainer.childNodes[0].linkedBrowser.finder.highlight(true, 'YOUR_WORD_HERE');

Getting text at clicked location in an HTML element

I have a div element containing some text. When the user clicks a word inside that div I'd like to highlight just that word.
In order to do this I need to know what character position in the text the click occurred at, so I can then locate nearby whitespace and insert some formatting around the word.
Finding out where the click occurred within the text is the trick here. Is that kind of thing possible?
If your page is auto-generated, you might consider pre-processing the page by putting a <span class = 'word'> around every word in every selectable div. You might be able to this with javascript after the fact, and I think that would be your solution regardless, but pre-processing would make it easier.
The problem with relying on the absolute position of the word is that users can scale their fonts, which makes this task especially hard. By wrapping a span around every individual word, you can easily select which word was clicked by applying the click event to the span elements.