How do I see the current encoding of a file in Sublime Text? - encoding

How do I see the current encoding of a file in Sublime Text?
This seems like a pretty simple thing to do but searching has not yielded much. Any pointers would be appreciated!

Since this thread is a popular result in google search, here is the way to do it for sublime text 3 build 3059+:
in user preferences, add the line:
"show_encoding": true

Another option in case you don't wanna use a plugin:
Ctrl+`
or
View -> Show Console
type on the console the following command:
view.encoding()
In case you want to something more intrusive, there's a option to create an shortcut that executes the following command:
sublime.message_dialog(view.encoding())

With the EncodingHelper plugin you can view the encoding of the file on the status bar. Also you can convert the encoding of the file and extended another functionalities.

For my part, and without any plug-in, simply saving the file either from the File menu or with keyboards shortcuts
CTRL + S (Windows, Linux) or CMD + S (Mac OS)
briefly displays the current encoding - between parentheses - in the status bar, at the bottom of the editor's window. This suggestion works in Sublime Text 2 and 3.
Note that the displayed encoding to the right in the status bar of Sublime Text 3, may display the wrong encoding of the file if you have attempted to save the file with an encoding that can't represent all the characters in your file.
In this case you would have seen an informational dialog and Sublime telling you it's falling back to UTF-8. This may not be the case, so be careful.

ShowEncoding is another simple plugin that shows you the encoding in the status bar. That's all it does, to convert between encodings use the built-in "Save with Encoding" and "Reopen with Encoding" commands.

plugin ConverToUTF8 also has the functionality.

Related

CSS Files Opening Up as Plain Text in VS Code

For some reason, whenever I create a new file and give it a css extension, the language mode is set to plain text. That is not the usual behavior and I don't know why it is acting that way.
Does anyone know how to fix that?
Thanks.
Click to the language at the right bottom bar of VSCode
Select Configure File Association for '.css'
Find CSS and select it.
You could run into problem cannot finding CSS in the last step I mentioned above, then here might be the fix for it btw:
Press Ctrl + , to open the Settings window.
Click Open Settings (JSON)
Find a line where there is
"files.associations": {
"*.css": "Plain Text"
}
and delete it, make sure the json file still in a correct format after deleting (no missing or extra comma ,).

Changing text file encoding does not effect the text

I tried to change the encoding of ANSI files (àìà ìùîåø) to UTF8.
I was manage to do that in the pass.
Now when i try to do the same thing, the encoding setting is changing but the weird character does not change and does not seems to get any effect.
I have tried with any good editors like notepad++ notepad2 notepad3 with no success.
I think that the problem is in my machine.
What could it be?
Thanks!
If you have Microsoft Office 2003 open Word copy the text and select it then go to tools -> fix broken text and choose your language. this will convert the text back to its original state

all spaces replaced by tabs when ctrl+shift+f

working in eclipse,when I type 'tab',it insert 4 spaces,it works well.but after ctrl +shift +f to format,all the 4 space will been replaced by tabs.how to stop it?
Window->Preferences->Java->Code Style->Formatter: Edit Active profile->Indentation->Tab Policy: Select Spaces
You can't change the default profiles so you must provide a new profile name, then press the Apply button, then the Okay button. It may help to press the Apply button once you have returned to the Formatter screen. Go back and look at the Tab Policy again to verify that your changes were saved.
Including the above suggestions, I recommend searching for code style or style to get to the coding standard being applied with the user requests formatting of the code. It is possible that the code style uses tabs instead of spaces.
The only way that currently works is to use Ctrl-A Ctrl-X Ctrl-V on all code after using Ctrl-Shift-F. This will replace all tabs with spaces.
Don't know which version of Eclipse you are using but for
Eclipse 3.6 (for example) you may go to
Window->Preferences->General->Editors->Text Editors->Insert spaces for tabs
This will change Eclipse to use spaces instead of tabs
The place in the Preferences may be different depending on which version of Eclipse you use. If you load the preferences window you can use the search function there to find "Formatters" and set your preferences for different types of files, or generally.

Is there a way to copy code from the Eclipse IDE without the rich-text formatting?

Recently every time I copy a block of code from Eclipse and paste the code into TextEdit or a online forum using the code tags, I get the code with the rich-text or html formatting, so I have to copy into a text editor remove the formatting copying and pasting again, In the past this was not a problem I used to copy from eclipse and paste the code without any formatting at all just as plain-text, I dont know if I turn on a property or what I did for this to happen, any ideas how to fix this?
There is an Eclipse bug filed for this that can be voted for:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=45969
It has been open for 10 years though!
There are applications out there that think they can handle rich text but can't. So for those it looks like we'll have to carry on with "Copy-Switch to Notepad-Paste-Select All-Copy-Switch to final app-Paste" for some time yet.
Note: the rich formatting from a SWT editor seems to have always been available (bug 64498).
You could use "Edit, Paste and Match Style" in TextEdit.
From the Edit menu, choose Paste and Match Style,
or use the keyboard shortcut, Shift Option Command V.
The pasted text will pick up all the formatting from the character to the left of the flashing insertion point. This technique works in Mail as well.

Unable to create a file with foreign language characters

I get the following error, when trying to save a properties file (containing name/value pairs) with foreign language characters. How do I set the encoding?
Save could not be completed. Some characters cannot be mapped using
"Cp1252" character encoding. Either change the encoding or remove the
characters which are not supported by the "Cp1252" character encoding.
I presume its eclipse:
Go to Windows Menu –> Preferences –> General (expand it) –> Workspace (click on it)
Look for a box “Text File Encoding”. Default will be “Cp1252″.
Change radio to select other and select “UTF-8″ from combo box.
That looks like Eclipse.
Cut the whole contents of the file into the clipboard.
Save the (now empty) properties file.
Change the encoding settings of the file (Alt+Enter) to be UTF-8 or whatever you need.
Paste the clipboard into the editor.
Save the editor.
Assuming it is in Eclipse, easiest way is to choose Save as UTF-8 option present in the error dialog box.
The other answers work well too.
Best possible solution for this , which I always do .Is to go the respective file in your workspace open it in notepad++ and make the desired changes. Once done , save the file.
Your eclipse will ask you to update the code with the changes . Click yes.
And you are all good to go now.
Fist copy the file and delete that file and then cleat your code in the eclipse after
create file with same content and rewrite the code it will resolve.