Sublime Text 3 AutoWrap breaks double quotes - sublimetext3

I installed a package called Sublime Wrap Plus to insert line break after wrapping text at 80 characters.
However, this breaks for example, the "long long long quotes" into
"long long long...
long quotes"
Which is a syntax error. Anyone knows how to fix this?

The README is clear about this plugin detecting where to wrap paragraph text, not source code. Based on their epilogue, you should open up an Issue for additional features.
Code wise, if you do want to add additional logic to the mix, its written in Python and uses if statements like this one to parse the selected area as you see fit.

Related

How to auto-break a long word when auto-wrapping text

I know we can use "word_wrap": "auto" in the User settings to make Sublime Text 3 auto wrap text, but how can I make it break a long word when wrapping?
In a sentence like:
a long word aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
I want it to
a long word aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaa
but not:
a long word
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
First, I saw advice to add "auto_wrap_break_long_word" : false, to the setting file, but it made no sense to me.
And then, I get advice from comments by using Sublime Wrap Plus
However, it is not what I want.
The Readme of Sublime Wrap Plus says:
Enhanced “wrap lines” command for Sublime Text 2 or 3. This is for the manual hard line wrap command. It does not affect the automatic soft line wrapping.
But what I want is not “HARD line wrap” because it will add real some line breaks and change the text file. And what I want is to break long word in “SOFT line wrap”(which will not change texts but only change how it looks)
In fact , I've tried to install the Sublime Wrap Plus package and set "WrapPlus.break_long_words":true in Preferences >> Settings — User.
But nothing changed about my SOFT line wrap.
THANKS for all advice anyway!

How to wrap lines of code or text in Sublime Text 3

I've searched for a while, and for whatever reason everything that comes up is a "hard-wrapping" or "auto-wrapping" solution. I wanted to know if there was a specific character sequence that I could use in the middle of string or the like to force it to the next line. I'm sure this has been asked before, but I couldn't find it. Thanks.

What does "Inconsistent use of tabs and spaces in indentation" mean?

I'm trying to create an application in Python 3.5 and i use spaces all the time for indentation, but the editor print out "inconsistent use of tabs and spaces in indentation" when it comes to
print("This car has "+str(self.odometer_reading)+" miles on it.")
How can i solve this problem? I'm a beginner in programming. I would be glad if i could get some overall tips on my code.
class Car():
def __init__(self,make,model,year):
#初始化描述汽车的属性
self.make=make
self.model=model
self.year=year
self.odometer_reading=0
def read_odometer(self):
#打印一条指出汽车里程的消息
print("This car has "+str(self.odometer_reading)+" miles on it.")
my_new_car.read_odometer()
It means that some of your code you've indented by pressing space and some of the code has been indented by pressing tab. You can tell which one is in use for a certain line by pressing backspace on the insert and if it deletes approx 4 characters worth of space it was an indent, otherwise it was a space. I would recommend that you either pick space or tab to indent your code then be consistent. To get your code working I would recommend you simplify remove all indentation then use either space or tab to indent.
Many editors support the display of the indentation mark and spaces.
Turn them on, you will see what the interpreter is talking about.
Its not possible to tell from your code displayed here. They have all be converted to spaces by syntax highlighter.

Remove Various Whitespaces While Editing in Vim

So oftentimes, while editing with Vim, I'll get into a variety of situations where whitespace gives me hassle. For example, say I have a comment like this:
#This program was featured on the Today show, it is an algorithm for promoting world peace in third-world countries
#given the name of that country and the name of a celebrity to endorse its cause
If I want to, for example, trim the lines so they go to X characters, I end up putting a newline somewhere in the middle of the top line to get this (after hitting the newline and auto-indenting):
#This program was featured on the Today show, it is an algorithm for promoting
world peace in third-world countries
#given the name of that country and the name of a celebrity to endorse its cause
I then add a # to the beginning of the line, and that's all well and good, but then I want that line to line up, too. To do so, I have to delete the newline, all the whitespace for the indent on the next line, and then the commenting # mark. It doesn't take an awfully long amount of time to do that, but this and similar situations all add up over a day's worth of coding.
Now the example above is pretty specific, but my question isn't. What's a good way in Vim to delete all whitespace INCLUDING NEWLINES up until the next non-whitespace character? If Vim already has movements that do that, that would be awesome, but if not, does anyone have a favorite Vim function they use to do the above that could be mapped to a key? At the very least, am I missing some Vim usage idiom that prevents me from even having to worry about this case?
EDIT: Formatting to width, while useful and applicable to the case above, isn't the focus of this question. I'm concerned more with whitespace removal that doesn't stop at the end of a line, but instead carries on to the first non-whitespace character of the next line.
You really just want to reformat that comment to fit the current 'textwidth'. If the comment is a paragraph (i.e., separated by a line of whitespace above and below), then you can just use gqip (gq is the reformat command, ip is the "inner-paragraph" text object) to reformat it. If it's not a standalone paragraph, you can visually select those lines and then use gq.
This likely also relies on having 'formatoptions' set correctly to make sure the comment characters are handled properly, but in many cases the ftplugin has already done that.
This is a while later, but I found that there is a command that does what I need to in 90% of circumstances:
J -- join line below to the current one
This command seems to work:
:.s/\W*$\n\W*//g
it uses a replace to remove whitespace up to end of line and the new line at the end.
In this example:
testting aad $
asdjkasdjsdaksddjk$
(to see meta characters in vim use the command :set list)
if you place the cursor on the first line and use the first command it will delete everything from aad to $ (not including aad but including $ and a newline.)
Also, note for what you are doing it is far more efficient to use an external program to format comments for you. In particular, par is a great small C program that edits text and wraps it to desired lengths.
If you have par in your path, to do what you are trying to do is as easy as selecting the block of comment with Shift+v and running the command
:!par 40pgr
where 40 is the desired width in columns.
If you are feeling hackish, write your own program in C/perl/C++/python that edits comments however you like, then put it in path and use the external filter command :! to process blocks of text through it.

Embedding text in AS2, like HEREDOC or CDATA

I'm loading a text file into a string variable using LoadVars(). For the final version of the code I want to be able to put that text as part of the actionscript code and assign it to the string, instead of loading it from an external file.
Something along the lines of HEREDOC syntax in PHP, or CDATA in AS3 ( http://dougmccune.com/blog/2007/05/15/multi-line-strings-in-actionscript-3/ )
Quick and dirty solutions I've found is to put the text into a text object in a movieclip and then get the value, but I dont like it
Btw: the text is multiline, and can include single quotes and double quotes.
Thanks!
I think in AS2 the only way seems to do it dirty. In AS3 you can embed resources with the Embed tag, but as far as I know not in AS2.
If it's a final version and it means you don't want to edit the text anymore, you could escape the characters and use \n as a line break.
var str = "\'one\' \"two\"\nthree";
trace(str);
outputs:
'one' "two"
three
Now just copy the text into your favourite text editor and change every ' and " to \' and \", also the line breaks to \n.
Cristian, anemgyenge's solution works when you realize it's a single line. It can be selected and replaced in a simple operation.
Don't edit the doc in the code editor. Edit the doc in a doc editor and create a process that converts it to a long string (say running it through a quick PHP script). Take the converted string and paste it in over the old string. Repeat as necessary.
It's way less than ideal from a long-term management perspective, especially if code maintenance gets handed off without you handing off the parser, but it gets around some of your maintenance issues.
Use a new pair of quotes on each line and add a space as the word delimiter:
var foo = "Example of string " +
"spanning multiple lines " +
"using heredoc syntax."
There is a project which may help that adds partial E4X support to ActionScript 2:
as24x
As well as a project which adds E4X support to Haxe, which can compile to a JavaScript target:
E4X Macro for Haxe

Resources