Insert Break After Wrapping Width 80 characters in Sublime Text 3 - sublimetext3

In sublime text 3, it will be nice if a line break is inserted after wrapping the code after 80 characters. However, I have not found this plugin yet. Does anyone know the configuration/plugin?
I found the link for wrapping lines after 80 characters. 80-characters / right margin line in Sublime Text 3

I successfully used regex find-replace in Sublime Text:
replace
(.{80})
with
$1\n

Check out AutoWrap. It will hard wrap automatically whenever you hit the ruler. It works nearly perfectly for me.

Related

Word wrapping a txt file in vim not working as expected

I am trying to edit a file on vim. You can download the txt file here.
I am following the instructions on this blog. I am also using what I read on StackOverflow.
First, I did this inside vim (command mode):
:set textwidth=80
Second, I used visual mode v to select all lines in the file. I started at the first line and the pressed G (goes to the last line). This made all the file selected.
Third, to reformat it, I did:
gq
Ok, the text is close to what I want. However, when I do this:
:echo max(map(range(1, line('$')), "col([v:val, '$'])")) - 1
The output is:
90
The command above shows me the length in characters of the lengthiest line. The output should be 80, not 90!
What I set as the limit of the text wrap was: 80
What mistake am I making? How can I wrap the text to 80 columns?
I started to use Vim this week. I am sorry if this question is too naive.
Your text width and reformatting is working fine, but the expression col is actually counting the "byte index" of the column position at the end of each line (not the character position). See :help col for all the info you need on how col works.
Instead, try using a character counting function like strchars:
echo max(map(range(1, line('$')), "strchars(getline(v:val))"))
On your example text I get an output of 83 because of the way the wrapping works on whitespace which count as characters. To take care of that, you could trim trailing whitespace with something like :%s/\s*$//, and now my example expression above using strchars returns 80 as expected.
:help col() gives you the byte index of the column. This would work as expected if you only had single-byte characters like c or a but your text contains a lot of characters like ç (U+00e7) or á (U+00e3) which are encoded with more than one byte so the count will be off for many lines.
What you actually want is to count screen columns, with :help virtcol().

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.

How to show invisible line endings in Sublime Text 3?

I would like to display invisible line endings in Sublime Text 3, as for example in Notepad++. How can we do that?
This is useful because when the automatic word wrap mode is ON for example, because it becomes hard to distinguish soft line breaks from real ones.
The package RawLineEdit is pretty good for this. It toggles on-and-off a mode where you view and can edit line endings by selecting Raw Line Edit: Toggle from the Sublime ctrlshiftp command prompt.
This is good if you want to be able to flick line endings visibility on and off on the occasions when you want to see it (it's not the best option if you want line endings to be always visible).
It's also very useful for seeing (and editing) if you've ended up with crlf problems, with windows-style cr carriage return characters getting mixed up with the standard lf line end characters shown as ¬:
I have written a basic plugin to display line endings as an explicit character, inline. There's certainly some room for improvement but it does the job.
It is available here: https://github.com/sdive/sublime-text_managelineendings
The other suggestions found here didn't work for the character I was encountering (U+2028). I found that this plugin was able to show me where the character was occurring:
https://packagecontrol.io/packages/Highlight%20Dodgy%20Chars
ctrl + shift + p on editor
now, type toggle word wrap and select it

Search for quotation marks doesn't work in Sublime

How do I search for quotation marks in sublime?
I need to replace "file.jsp"/> with "file.jsp"> in more than 100 files
Is this possible to do in sublime using replace tool ?
I already tried backslash and it doesn't work. Any other solutions please?
Make sure that the option whole word (Alt + W) in the replace toolbar is turned OFF

Vim - Select text in between parentheses, multiline

value(val_1)
value(val_100)
value(val_10)
I want to select text between parentheses and do it for multiline, for one line I can use f(va( but I don't know how to select for 2 remaining lines.
EDIT (SOLUTIONS)
What I want to is to change text inside parentheses with unique text every line, firstly, I was thinking to select the text, delete it then change the text manually, #rosipov tell there is a plugin to do the selection part and it's great, but #romainl gave me another direction that works too.
f(ci(foo<Esc>jci(bar<Esc>jci(baz<Esc>
Do you want to select this:
value([val_1])
value([val_100])
value([val_10])
or to select that:
value([val_1)]
[value(val_100)]
[value(val_10])
The first is unfortunately not doable. But depending on what you want to do with the selected text, change it for example, a reasonable approximation would be:
f(l<C-v>jj$cnew value)<Esc>
However I'm sure a lot of Vimmers would probably approach the problem with a substitution:
:,+2s/(.*/(new value)
The second is done simply with:
f(lv3/)h
or
f(ljjt)
You will probably be interested in EasyMotion plugin in this case: https://github.com/Lokaltog/vim-easymotion
With plugin it will be: f(vLeaderLeaderf)c
Or: LeaderLeaderf(avLeaderLeaderf)c
Where c is letter representing 3rd closing parentheses, a represents first opening p.
EDIT: Without plugin it is possible to do it by line number.
Assuming that you work with lines 1-3: f(v3Gf)
Where 3G stands for "go to line number 3", works in both visual and normal modes.

Resources