Set word wrap for plain text only - sublimetext2

I want word wrap off for everything except plain text.
I've added "word_wrap": false to my Preferences.sublime-settings and then created Plain Text.sublime-settings.
Plain Text.sublime-settings is in ...AppData\Roaming\Sublime Text 3\Packages\User and contains:
{
"word_wrap": true
}
However, the pain text file remains unwrapped.

To set settings for a specific language, do the following:
Open up any file with that syntax type
Go to Preferences –> Settings–More –> Syntax Specific–User
This should open up the correct file for your language-specific preference settings.

Sublime text is case sensitive on the file name.
Plain Text.sublime-settings <== Bad
Plain text.sublime-settings <== Good
`

Related

Turn html text into markdown manually (javascript / nodejs)

I'm a bit stuck. I have scraped a website and would now like to convert it into markdown. My html looks like this:
Some text more text, and more text. Some text more text, and more text.
Once in a while <span class="bold">something is bold</span>.
Then some more text. And <span class="bold">more bold stuff</span>.
There are html to markdown modules available, however, they would only work if the text <b> looked like this </b>.
How could I go through the html, and everytime I find a span which is supposed to bold something, turn this piece of the html into bold markdown, that is, make it **look like this**
Try this one https://github.com/domchristie/to-markdown, an HTML to Markdown converter written in JavaScript.
It can be extended by passing in an array of converters to the options object:
toMarkdown(stringOfHTML, { converters: [converter1, converter2, …] });
In your case, the converter can be
{
filter: 'span',
replacement: function(content) {
return '**' + content + '**';
}
}
Refer to its readme for more details.
Notepad++ is an open-source editor that supports regex. This picture shows the basic idea.
You know how to use an editor to find and replace strings. In an editor like Notepad++ you can look for string patterns and replace parts of the patterns and keep what's left. In your case, you want to find strings that are framed by HTML markup. Here the regex in the 'Find what' edit box displays that, with the special notation ([^<]*) meaning save zero or more of any character other than the '<' for use in a replacement string. The 'Replace with' edit box says used what was saved (as \1) in the expression **\1** which gives you what you prefer to have in the text file. It remains to click on 'Replace all'.
To be able to do this you need to install Notepad++ and learn some basic Perl regex. To get this dialogue box click on Ctl-H. Of course, if you get it wrong there's always Ctl-Z.

After "a{display text}", then pasting the url, how can I get the cursor to go after the close </a>? Like $0 in a Sublime autocomplete

I'm using Emmet in Sublime Text 3.
After executing a{display text}, you get
display text
What I'm trying to do is get the cursor to jump to after the close </a>, after I've pasted in the url. I'm trying to simulate Sublime's autocomplete $0 behavior, like
display text$0
I am looking through snippets.json, but I'm not getting it. The only "a" entry is in the "abbreviations" object, and contains only the open tag:
"a": "<a href=\"\">",
I've not edited any Emmet tags before, and I thought this might be a good first one to try.
Any ideas on how this might be possible?
There's a built-in Emmet setting that does this for all tags:
This is in C:\Users\jeffy\AppData\Roaming\Sublime Text 3\Packages\Emmet\Emmet.sublime-settings
// If set to `true`, Emmet will automatically insert final tabstop
// at the end of expanded abbreviation
"insert_final_tabstop": false
I duplicated it to C:\Users\jeffy\AppData\Roaming\Sublime Text 3\Packages\User\Emmet.sublime-settings
and changed it to true. It does exactly as I want. Well, it still goes to the display text, even if there already is display text. Then it goes to the end. But close enough!

Sublime Text 2 - Problems with HTML automatic indentation

Every time I type an opening html tag (like <div>) then press the Enter key, the cursor automatically inserts an indention on the next line. However I don't want it to be indented since I still have to write the closing tag (actually I press the enter twice and write the closing tag in the third line so I can have an empty line in between). Now I have to press the back button to align the cursor with the opening tag.
I am aware of Sublime Text 2's autocomplete like when you type '<' and Ctrl + Space, a list
of available elements would appear. And when you select one item from the list, the editor would
provide you of both the opening and the closing tag. However, I'm not used to that kind of typing.
So is there a way to turn off this annoying feature of Sublime Text 2
You can disable auto-indentation by setting auto_indent to false.
In order to do this for the HTML syntax only, go to Preferences/Settings – More/Syntax Specific – User and insert the following contents:
{
"auto_indent": false
}
This will make the cursor to jump back at column 0 after hitting return.
To make it stay at the column of the opening tag, re-enable auto_indent and tweak the indentation settings in Packages/HTML/Miscellaneous.tmPreferences. If you aren’t into regular expressions, try to get rid of this file completely.
You can also just type the closing </div> tag and sublime text will automatically un-indent it for you.

Insert same code around different filenames

I am making a small online database that is accessible through the form of checkboxes for download. I was wondering if there was some way to list all of the filenames available for download in Sublime Text 2 and insert the same code around each filename?
Everything is functional, it would just save me a lot of repetitive copy and pasting if there is a faster way to do this.
Use SublimeText Find & Replace. Click the Regex button (it looks like a * to the left of the search box)
In the Find box, insert: (^.*$)
In the replace box: [yourcode]$1[yourcode]
Where [yourcode] is what you want to insert into the box.
So, if you want to make them all <li> then your replace box would be:
<li>$1</li>
Remember to use escape \ characters where they are needed, in case you need to insert restricted characters.
^ - beginning of a new line.
. - wildcard
* - any number of the previous character in the sequence (in this case a wildcard, so any text)
$ - the end of a line
() - denotes a block, it's how the $1 knows what text to put in it's place.
Sublime Text Search and Replace
Use search/replace on a text editor with regular expressions.
^ and $ represent the beginning and end of a line - thus allowing you to easily surround each line with the appropriate text.
Sometimes you can copy the newline character (as in copy the end of one line to the beginning of the next line), and replace that with whatever text you need.
You could always use the regular expression search / replace feature in Notepad++.

Sublime Text 2: soft wrap lines -> reverse indentation?

I've started using Sublime Text 2, and its community of plugins, as my Dreamweaver replacement (thank the Gods). I love Sublime and clearly won't realize many of its features for months or years to come, but there's a simple setting I've had trouble figuring out.
I've used BBedit lots in the past. One feature I'm very attached to is the ability to "reverse" indent lines when soft-wrapped, such that line wrapping looks like this:
Text text blah blah blah blah long enough to wrap
to a new line blah whenever soft wrap happens it
reverse-indents like this.
Here's a new line with no indent.
Maybe I shouldn't be so married to a seemingly minor feature, but I find it much easier to read code when it's not possible to confuse the beginning of a line with "tailings" of a long line. Does anyone know how to do this in Sublime?
After further use, I think I've figured this out. Apparently Sublime's default (and only) behavior is to reverse-indent code lines, but leave html lines flush. So when I'm editing a PHP/HTML document, my wrapped lines will reverse-indent about half the time, depending on whether I'm in an tag or in a fragment at that line break.
The effect on my code is something like this:
<!-- Wrapped HTML doesn't reverse indent -->
<a href='long_link_that_causes_lines_to_wrap' other_attribute='
jquery_thing_that_makes_lines_wrap'>something</a>
...
<!-- Wrapped PHP snippets do reverse indent -->
<? echo date('M jS', strtotime('some_interpolated_formatting_string',
$some_variable_expression)); ?>
Sublime uses JSON files to store your preferences. The default file lists the settings that it uses by default, and you can override them by adding them to your user file.
The preference that controls hanging indent is word_wrap:
// Disables horizontal scrolling if enabled.
// May be set to true, false, or "auto", where it will be disabled for
// source code, and otherwise enabled.
"word_wrap": "auto",
As shown above, the default value is auto which only wraps lines that are not considered source code. To get hanging indent on all lines in a file, you need to set it to true in your user preferences file:
"word_wrap": true,