Set Default Syntax for a New Created File in Sublime Text 2 - sublimetext2

In Sublime Text 2, when I double-click on the tab bar, it will create a new file, Sublime Text 2 will give it Plain Text syntax, How to change this default Plain Text syntax to HTML syntax?
I know there is a sublime-DefaultFileType that could set the default file type of new files which are created with the Ctrl+N. However, how can I make it take effect when I double-click on the tab bar to create a new file?

I'm afraid there isn't a solution for double click.
According to the official website, DefaultFileType
This only affects files which are created with the Ctrl+N shortcut (Cmd+N on OSX).
for installation, follow the Installation part.

Please refer to this stack post: (On Text 3 it also works fine)
Sublime Text 2 Default File Type on new file
This py code solution support double click. DefaultFileType might be an easy option. But it didn't work in some cases, it has been 5 years old. In fact, I have to use this method for text 3 on windows.
This is the syntax for SQL :
http://rouge.jneen.net/pastes/PNq0
save it like DefaultLanguage.py
use the default location : \Data\Packages\User

Related

How to use sublime text 2 like notepad++

In Notepad ++ we can use Move to other view for copy/paste attributes easily . But How i use sublime text 2 like two windows at a time for copy/paste attributes easily ?
If I understood your question right you will find the answer by accessing sublime's menu View>Layout>... Columns

Sublime Text 2 always opens empty window

I am opening a Sublime Text 2 project with the following command using gksudo in order to be able to edit some system files:
gksudo /usr/bin/subl /home/orschiro/.sublime/system-administration.sublime-project
However, what Sublime does is it opens the project in a window but additionally shows another empty window:
I already tried adding the following to the project and user settings but it does not resolve the problem:
"open_files_in_new_window": false,
"hot_exit": false
Does anyone have an idea how I can stop Sublime from opening that additional empty window?
You can try "create_window_at_startup": false, but that might only apply to OSX. Another option is to try "close_windows_when_empty": true.
Is your /usr/bin/subl a link to /path/to/Sublime Text 2/sublime_text, or do you have a -w specified as well? The -w option is not needed, so that's another thing to look at.
Good luck!
In your settings file, try:
"create_window_at_startup": false
I know this is an older issue and only for ST2 but none of these fixes worked for me on ST3. I was able to fix it by removing sublime text 2 and re creating my symlink with sublime text 3 (even though that is what it was linked to already). It seems it may have been confused by the multiple applications.

Sublime Text 2 tab_size setting not correctly activated

I have the following in my user/Preferences.sublime-settings
{
"tab_size": 2,
}
And most of the time it works. But once in a while I open a ruby file, and it jumped back to 4 spaces. I'm wondering if there is some bug or slight difference in opening a file that could change this?
Having trouble tracking this down. Thanks for the help.
You'll want to add:
"detect_indentation": false
This is on by default and ST is trying to be smart detecting the indentation of your current file, overloading the user or syntax specific default.
Here are various Sublime Text 2 tab settings explained:
http://opensourcehacker.com/2012/05/11/sublime-text-2-tips-for-python-and-web-developers/#Configure_sane_tab_and_whitespace_policy_and_other_settings
Note that the tab setting may be per file type
There is also autodetect from file enabled by default and your source code file may contain bad tabbing

Changing default syntax based on filename

In Sublime Text 2, I've seen ways of basing the syntax off of the extension. But what about a filename with no extension? For example, I often have a file called "Vagrantfile" which is in ruby, yet Sublime Text 2 always wants to start off in plain text. Is there a way to have it default to "ruby" for a file if it is called "Vagrantfile"?
With Sublime Text 2.0.1, build 2217, look in the lower right of the window, where it says "Plain Text" for the Vagrantfile that is open.
Click that and in the menu that opens, at the top, there will be an "Open all with current extension as ..." sub-menu. Go into that sub-menu and choose Ruby.
Even though the Vagrantfile has no extension, Sublime will remember this and open Vagrantfiles with the Ruby syntax as expected. This does not spread to all files with no extension.
Add the following line to the Syntax Specific - User file in
Preferences > Setting - More > Syntax Specific - User
for permanent staying of the syntax for every Vagrantfile file.
{
"extensions":
[
"Vagrantfile"
]
}

In Sublime Text 2 How to view carriage return and line feed?

In notepad++ there is a toolbar button to switch on/off display of EOL characters, i.e. carriage return and line feed.
Can Sublime Text 2 do the similar thing?
In case anyone is here years later, I found success with the sublime package RawLineEdit.
Install with Package Control
Enter Raw Line Edit: Toggle into the command palette (via Ctrl+Shift+P)
Further documentation of features can be found in the User Guide.
Note that this package is only supported in Sublime Text 3.
Sublime Text does not currently support displaying EOL characters.
http://sublimetext.userecho.com/topic/104394-is-it-possible-to-show-all-characters-spaces-tabs-cr-lf-etc/
There is a quick workaround, in the search, enable the Regular expression and the search value use \n. You will see all the line feed is highlighted.
05 2021
This might not really helpful for OP question and also the question is 8yrs old and iam assuming he must have got a answer pretty early on.
This is anyone still looking for the answer to show the carriage return in Sublime text 3.
As on May 2021 the current version is 3.2.2
Detailed version of #Sam YC answer
Tested in Sublime text 3
Press Ctrl+ F (Windows)
Select the first box 'Regular Expression (Alt+R)'
Also select 'Highlight matches' (Last box with plain border)
Enter \n
You should see something like this. If you do not see anything, just toggle the 'Highlight matches'.
There is another way to achieve this.
Go to preference -> choose "settings-user"
In the file opened paste this command.
"ensure_newline_at_eof_on_save": true