Set line endings for all tabs and all open files - sublimetext

Some of my files/tabs somehow got to be Unix line endings, when I want Windows line endings. I can go to view > line endings > windows, but that applies it only for the current file/tab opened. I don't want to have to do it for every file (which I did). But even if I do this, when I open other files, sometimes they are set in Unix. Is there a single setting that can apply it for all files, whether they are opened or unopened?
If I go to preferences > Settings - default > and go to the default_line_endings setting, its value is set to 'system'. I know i COULD override this in my 'Settings - User' setting, but I didn't have to do this before the line endings somehow got all messed up. Is there another way?
Also, If i reinstall sublimetext, would this fix it, or are the line endings somehow dependent on the files themselves? I imagine it would be sublime text that decides which line endings to use, perhaps based on what line endings are in the file. But I don't know this for sure. Plus, all my line endings used to be the windows's CRLF, not Unix's LF.
Controlling the line endings in sublime text is currently kind of a pain, since it has no en masse way to view or set, current files, nor an en masse way to set it for future files.
Any knowledge would be appreciated.

The Line​Endings plugin / package is small, but works like a charm Visit it's GitHub repository to get a few details, because on its Package Control page there is no description.
It not only works, but also gives you an additional functionality -- you can change not only line endings, but also indentation method of all open files in one step.
After installation:
Open all files, in which you want to convert / change line endings and/or indentation method.
Press Ctrl+Shift+P, to bring Command Pallete and start typing lin to locate Line Ending to all views: Windows (for example).
Select it, hit Enter, and... you're done!
Repeat step 2, but type spaces to locate Indentation: Convert to all views to Spaces or tabs to locate Indentation: Convert to all views to Tabs to change indentation method of all open files.
Note, that either this plugin has a bug or Sublime Text 3 gets sometimes a bit wako. Some searches did not reveal above mentioned commands. And I had to close and reopen Command Palette and type sequence again. Especially, if you have any kind of linter installed in ST3, its command may interfere with Line​Endings's commands, as you type lin.

There is a plugin that will do what you want sublime-line-endings-unify.
The default_line_endings setting will only affect new files. Sublime will use whatever line ending is already there for existing files. Perhaps you have a tool (such as your source control system) that is changing the endings. Sublime itself will not change them unless you explicitly change it.

Related

Is there integrity check in PE files?

I am trying to edit some portable executable file with text editor.
In the top of the file a backward compatibility string is supposed to display messages on DOS systems.
This program cannot be run in DOS mode.(click the link to see screenshot)
I first tried to edit this string by replacing a char (not removing or adding : just replacing to not change the file size). Then when I try to execute the file windows return an error saying I can't run this app on my computer.
I also tried to edit the padding at the very end of the file and the error is the same.
I suppose an integrity check is performed. Did someone already read about this? If you did, do you know if/where the file hash is stored in it?
A text editor is not appropriate for editing binary files. Use a hex editor instead.

github/gist - How to paste multi-line text (without line breaks getting removed)

When i copy&paste multi-line text (from sublime3 or terminal) into Github/gist web inputbox i can see my text properly formatted (for a glimpse of a second). Then gist immediately removes all line breaks and fits everything into one line (see pic below). How can i prevent this?
Arch Linux, Firefox 58.0.2
picture: https://abload.de/img/gistx1rn6.png
Try starting Firefox without any plugin (safe mode), because I just tested several copies from Sublime Text3 to a gist in Firefox (latest version), and I did not reproduce the issue.
My file can use CRLF or LF end-of-line characters, in both cases, the lines are preserved.
For testing, try those Arch Linux commands to put a text in the clipboard, and see if the issue persists when said clipboard is pasted to the Gist.

How to run Octave from a Notepad++ file line by line or by sections?

I am looking for a way to have my Notepad++ window open for editing my code and run it line by line or by sections (more than 1 line) while I am editing. It would be like having a real IDE; the output could be shown in the same window (Notepad++) or directly in the Octave window.
I have tried what many many sites say. That is, writing this:
C:\Software\Octave-3.6.4\bin\Octave\Octave-3.6.5.exe "$(FULL_CURRENT_PATH)"
in the Run window in Notepad++, saving and giving it a shortcut. However, it is still not working. When I tried to run it, the black window starts showing-up but then it disappears and nothing else happens. In my Notepad++ window I have only one line (for now) where I have tried just "b=4" or "3*4". I have done this with and without semicolon at the end. Nothing happens.
I have Windows 8.0, Notepad 6.5.5 and Octave-3.6.4. I already change the octaverc file in Octave to make it work with Notepad++. I have work already only in the command line in Octave and is working fine. The Octave I installed was exactly "octave-3.6.4-vs2010-setup", it says it was compiled for Visual Studio 10. Is that the reason why this is not working?
Any help will be appreciated...
regarding Octave not processing the command: use supposed command line outside the N++ and see if it works. If not, find a way to make it working, then transfer it back to N++ (and use the token "$(FULL_CURRENT_PATH)" instead of concrete filename)
regarding running the code in smaller portions: if you app can accept the code directly in the command line (SQL command line tools I use can do this), then you can use token "$(CURRENT_WORD)" what stands for content of current selection (all tokens are in wiki)

ActivePerl. .pl files no longer execute but open in Notepad instead

I have perl scripts which were running in Windows 7 just fine as of this morning. I made the mistake of using NotePad as the default for opening/editng my .pl files. Now, when I attempt to run the unedited .pl files from a DOS prompt, the script does not execute but opens the associated source code file in Windows Explorer. This is the same for all my .pl files no matter the complexity (including classic "hello world".
I have been researching changes need to the registry - it all looks fine. Tried assoc and ftype changes - nothing. Tried reinstalling ActivePerl - no solution.
You don't need to go into the Registry.
Go into Windows Explorer.
Find a file that ends in a *.pl suffix.
Right click on it and bring up the Context menu.
Select "Open With" (It might just be Open... with an ellipse after it. I don't have a Windows machine at the moment to verify this). This will bring up a dialog box with all the various programs. NOTE: Perl may not be listed in the initial set of programs. No worry, just navigate to it.
On the bottom of the dialog box is a checkbox (Something like open all extensions with this program). Make sure that checkbox is checked.
After this, all files that end with *.pl will open with Perl instead of Notepad.
It is highly likely that someone did this with a Perl script in order to edit it, and messed up the file association.
However, who ever did this should be doped slap -- not for messing up the file association, but for editing a program with Notepad. Bad Developer! No doughnuts for you!
Programs should be opened with a Program Editor. If you're a real he-man, you can use VIM. VIM is a fast, and powerful program editor, but you will need to spend an internship at the feet of a VIM Ninja master in order to learn how to use it. Your first three to six months with VIM will be What a idiotic program! This is awful. Who wrote this crap?. Then, one day, you will understand its power and efficiency. You will be one with the program.
If you aren't brave or fearless or don't have six months to waste learning a programming editor, you can use Notepad++. Compared to VIM Notepad++ is like driving a Minivan. It's safe, it's practical, and it gets the job done.
Both editors do Syntax Highlighting which can help you find issues. Both, (VIM can -- I think Notepad++ can too) offer help with syntax and usage. Both can edit a file without messing up the line endings (They'll both detect whether a file has Unix or Windows line endings and keep those or allow you to convert them). Both will number your lines, have extensive cut/paste buffers, powerful search and replace features. And will not mess up your file encoding. Both offer visual diffing between files and do automatic backups when you edit a file.
Finally, these two editors will embed themselves into the context menu you get when you right click on a file. You can edit a file by clicking on it, and selecting VIM or Notepad++ directly from the context menu. No need to select "Open with..." and possibly mess up the file suffix association.
Never ever use Notepad to edit a program.
Sounds like your .pl extention association is now set to Notepad rather than perl.exe. If you are too busy to fix that, just type "perl yourscript.pl" in a command promot window to start the perl interpreter and to send your script to it to run.
See this answer to fix the association:
File Type .pl Association and Using cmd.exe to Run the Script
I have the same problem. None of the method mentioned above solve the problem. The problem actually came from Windows 7! Windows 7 Doesn't allow you to associate .pl to perl.exe in c:\Perl64 directory, for whatever reason.
Here is the solution:
If you look at c:\Perl64\Bin directory (or the path where your ActivePerl binary installed), you'll see another file: Perl5.14.2.exe. This is the same file as perl.exe in same directory but with version number attached as postfix in the name.
You can associate .pl file to that Perl5.14.2.exe instead of perl.exe. Bingo, it works now.

Uploading php files via FTP, all linebreaks and CRs are lost upon upload

I can download files I have no uploaded and carriage returns are in tact however upon upload my files are placed on a single line.
This is making it difficult to troubleshoot this app as there is an error but everything is on line 1.
Why is this happening?
It's unlikely that FTP will "put everything on one line". More likely is that the file uses *nix-style line endings and you uploaded the file in binary mode to a Windows machine, or something like that.
See, different platforms have different sequences of characters to represent "new line". In Windows, that's most commonly CR+LF, but on *nix, it's just LF. Problem being, lots of software assumes stuff about what line ending a text file should have, and if it sees a LF character, it doesn't see it as a newline character. So everything looks like it's on one line. (I didn't think PHP was so anal about line endings, but i've seen other languages that freak out over it.)
Binary mode transmits the file byte for byte, and doesn't convert line endings. Which is great if you're down- or uploading an image or something. But if you're transferring text files in binary mode between machines running different OSes, you're likely to see the results of "incorrect" line endings.
The solution: Use ASCII mode for PHP files. Most FTP clients have settings for what mode to use, and even what mode to use for certain types of files. Since PHP files are text, they should probably be transferred in ASCII mode in most cases.
Solution that worked for me:
Use Atom.io editor
Install the Atom package line-ending-converter
Open the file in Atom > mark all > right mouse click > Convert Line Endings To > Unix Format
Save file and upload to server (if JS file, open in browser to see if the linebreaks are correct now)
Some background information from here:
When downloading a file with Windows line-endings (CR+LF) in a text/ASCII mode, the server replaces LF with CR+LF, resulting in an incorrect CR+CR+LF. When opening such file in an Internal editor of WinSCP, the editor interprets the sequence as two line endings (CR and CR+LF) resulting in a blank line after each and every content line. When the file is saved, the internal editor saves two Windows line endings CR+LF and CR+LF. On upload they get converted to two LF’s. A workaround is to use an external editor and make sure WinSCP does not force text mode for edited files.

Resources