Sublime text useful questions - sublimetext2

I think most of us sublime text users have one or more of these questions. Let's get it answered here:
1) What is the default font of Sublimetext and where can I download it from?
It says:
"color_scheme": "Packages/Color Scheme - Default/LAZY.tmTheme",
"font_size": 11
But what font it is? It looks good.
2) How can I make the brackets bold and red/other color when I point there?
Currently, I can see there is small line underneath the brackets but it is not bold nor it is any color
{
code
}
3) Can I run Python/Java code from sublime text?
4) How can I print a file using sublime text?
5) Is there any easy way to comapre files using sublime text?
6) Can I run MySQL queries from sublime text?
Thanks!

1) Emilbus Mono
2) There is a nice little plugin available that allows you to customize the matching tag highlighting style and behavior: https://github.com/facelessuser/BracketHighlighter
3) Tools > Buils System... > Python
4) There is no direct way to print from ST, but you can use something like the sublime text to html plugin
5) https://github.com/colinta/SublimeFileDiffs or an external tool like Kaleidoscope for Mac.
6) Try SublimeMysql on github

4) No you can't print from Sublime Text.

You can use 'Tools' -> 'Build System' -> 'Python' or 'Java'
It has not such feature. But you can use plugin https://github.com/joelpt/sublimetext-print-to-html and print from a browser.
Plugin https://github.com/colinta/SublimeFileDiffs
'Tools' -> 'Build System' -> 'New Build System'
{
"cmd": ["mysql", "-u", "USERNAME", "-e", "source $file"],
"selector": "source.sql"
}

Related

Can't change fontFace in Windows Terminal

Trying out Windows Terminal customization via settings.json. I found a profiles.json that follow the new conventions closely enough to work when pasted into settings.json, (I know it took because the theme changed). The problem is that changes to "fontFace" are not having any effect. I'm trying to use a nerd font for some powerline stuff, works in Powershell running in ConEmu but not in Windows Terminal. Here is the relevant portion of settings.json:
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
// You can add more global application settings here.
// To learn more about global settings, visit https://aka.ms/terminal-global-settings
// If enabled, selections are automatically copied to your clipboard.
"copyOnSelect": false,
// If enabled, formatted data is also copied to your clipboard
"copyFormatting": false,
// A profile specifies a command to execute paired with information about how it should look and feel.
// Each one of them will appear in the 'New Tab' dropdown,
// and can be invoked from the commandline with `wt.exe -p xxx`
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"profiles":
{
"defaults":
{
// Put settings here that you want to apply to all profiles.
"cursorShape": "vintage",
"fontFace": "Iosevka Nerd Font"
},
"list":
[
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"fontFace": "Iosevka Nerd Font",
"colorScheme": "PowerShellTom",
"useAcrylic": true,
"acrylicOpacity": 0.8
},
{ ...
I get the same behavior in Windows Terminal Preview, which is supposed to be the least "bleeding edge" version.
Even trying non-nerd fonts for "fontFace" has no effect, however, "fontSize" will work.
For people who are coming from SCOTT HANSELMAN article (especially from the third step)
Install Cascadia Code for all users
Change the "fontFace" property in the settings.json like this
Shortcut to open settings.json: Ctrl+Shift+, (comma)
here is the code to copy
"profiles": {
"defaults": {
"fontFace": "Cascadia Code PL"
// Put settings here that you want to apply to all profiles.
}
}
This is the only way I made that work (after 2 hours or trying)
Change the fontFace from "Iosevka Nerd Font" to just "Iosevka"; the fontFace attribute expects a font family, as far as I'm aware this isn't in the documentation and I only found it out after reading this issue on the WT github
I wanted to install MesloLGS NF Regular as a recommended font for Powerlevel10k in WindowsTerminal for WSL:
https://github.com/romkatv/powerlevel10k/blob/master/font.md
To make it work I had to:
Install it for all users as #hakan-fıstık showed in his answer.
Change the "fontFace" in settings.json to "MesloLGS NF" (Supplying full names of fonts is not working as supposed to).
Be sure to change size of font (changing font may make it huge): https://learn.microsoft.com/en-us/windows/terminal/customize-settings/profile-appearance
From a comment to the Issue I opened on Windows Terminal's GitHub page, (#6606), I was directed to another fontFace problem where choosing another font would not stick if you reopened WT, (not quite the problem I was having).
Anyway, the current solution to that is to uninstall any font you want to use, then right-click and choose "Install for all users". Double-click the file to open the sample view, and use the font name found just below the the two buttons. use the spaces in the font name as is in your settings.json file.
This worked for MesloLGL NF, but not Iosevka NF.
In my experience, editing the 'settings.json' file manually creates more issues than it resolves. The easiest way to edit the default font of your terminal is as follows:
Open the settings
Select Ubuntu under the 'Profiles' header on the sidebar
Scroll down to 'Additional Settings' and select 'Appearance'
Under the text header, change the 'Font face' attribute to your preferred font
Open 'settings.json' to view changes
You should see the expected format for selecting a font - Should you wish to edit the json file manually, you should follow this format
Save changes and exit

No HTML suggestions in Visual Studio Code

I've download the latest Visual Studio Code and am trying to write some HTML code. For example, <div>, <a>, <p> tags. However, there are no HTML suggestions in Visual Studio Code:
I've read this article and it says:
Visual Studio Code provides basic support for HTML programming out of
the box.
However, I've tried to install HTML extension:
In addition, I've turned on HTML5 suggestion in settings.json file:
{
"workbench.colorTheme": "Visual Studio Light",
"workbench.activityBar.visible": true,
"editor.multiCursorModifier": "ctrlCmd",
"window.zoomLevel": 0,
"html.suggest.html5": true,
}
Nevertheless, HTML, CSS suggestion does not work.
What can I do to code with suggestions?
I think the issue is that Visual Studio Code is not detecting the file type correctly. If you notice in these pictures, vscode has correctly detected that I am writing a html file by the icon <> beside the file name and the language indicator in the bottom right of the screen.
The language indicator most likely says plain text in your case. Click on it and a menu should appear at the top centre of the screen. Then try the following:
Enabling Auto Detect. I think this will be the first option.
Selecting Configure File Association for '.html'...
2 can also be accomplished by adding
"files.associations": { "*.html": "html" }
to your settings.
OR just add to settings.json (File -> Preferences -> Settings):
{
// Configure file associations to languages (e.g. "*.extension": "html"). These have
//precedence over the default associations of the languages installed.
"files.associations": { "*.html": "html" },
}
Just go to "File -> Preferences -> Settings"
Search for "Associations"
Check this image
Go to
File > Preferences > settings > Extensions > Emmet
Then click on
( C:\Users\Code\User\settings.json ) #
for reference
Add the following code:-
"emmet.triggerExpansionOnTab": true,
"files.associations": {"*html":"html"},
Save the file.

Create a shortcut in BRACKETS to execute HTML files in Firefox

I've been struggling to find out a solution with a Bracket extension or whatever to create :
--> a shortcut in Brackets to execute HTML files through Firefox.
I usually use Sublim text, and I created a simple "Build System" to open the html file in Firefox when I strike cmd + B. But I can't find the equivalent with Brackets
(In Sublim text, I used :
{
"cmd": ["open", "-a", "Firefox", "$file"]
}
)
I hope I've searched enough before asking this question! Thanks !

Comment snippets package of sublime text is not working in css

I installed sublime text and included comment snippets (https://packagecontrol.io/packages/Comment-Snippets) it's working in html and others languages but it doesn't work in css whenever i wrote my comments like this:
comm-section
it gives me this output:
comm-section: ;
in html
/*=============================================
= Section comment block =
=============================================*/
/*----- End of Section comment block ------*/
how to be fixed in css like in html
Thanks for replying
I've had this problem before, the main reason why this isn't working is because you have "EMMET" package installed and it's overriding it.
If you find yourself not really using EMMET's shortcut for css, you can disable it in EMMET's settings.
Go into Sublime: SublimeText -> Preferences -> Package Settings -> Emmet -> Settings User
Open it and type in:
{
"disable_tab_abbreviations_for_scopes": "source.css"
}
Save it, then try your comments again. It should work now.

Is there a way to prevent Sublime Text from previewing binary files inside the text editor?

As the title suggests, I would like to find out if there's a way to prevent ST2 from opening binary files when I click on them. For example when I click on an image, there's no point displaying the hex representation inside the text editor.
One additional note: I'm not interested in hiding binary files from the sidebar.
Files containing null bytes are opened as hexadecimal by default
In your User or Default Settings file:
"enable_hexadecimal_encoding": false
Unfortunately I'm not aware of a way to disabled previewing of specific formats, but if you want to avoid accidental clicks on enormous binary files that may slow down the editor you could disable all previewing from sidebar clicks.
In your User or Default Settings file(s):
"preview_on_click": false
I have similar situation like you. I dont want sublime open editor for binary like jpg png files. Instead open system default application is more reasonable.
Create one Build. Refer to Sublime Text 2 keyboard shortcut to open file in specified browser (e.g. Chrome) It will both open default application and hex editor.
Plugin OpenDefaultApplication https://github.com/SublimeText/OpenDefaultApplication
It will have context right click menu OpenInDefaultApplication. But It will both open default application and hex editor as well
Plugin: Non Text Files https://packagecontrol.io/packages/Non%20Text%20Files Add config in the user setting
"binary_file_patterns": ["*.JPG","*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds", "*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip"],
"prevent_bin_preview": true,
"open_externally_patterns": [
"*.JPG",
"*.jpg",
"*.jpeg",
"*.JPEG",
"*.png",
"*.PGN",
"*.gif",
"*.GIF",
"*.zip",
"*.ZIP",
"*.pdf",
"*.PDF"
]
I choose the third way, it's quite suitable for me. It will open jpg file in system default application and quickly close the edit mode automatically.
For Sublime Text 3
file_exclude_patterns Setting
If your binary files have a file extension, then yes.
In your Sublime Settings you can use this setting to prevent you from seeing the files in the left project folders:
"file_exclude_patterns":
[
"*.db",
"*.dll",
"*.ds_store",
"*.egg",
"*.enc",
"*.eot",
"*.exe",
"*.ko",
"*.otf",
"*.pdb",
"*.pdf",
"*.pgn",
"*.plist",
"*.psd",
"*.pxm",
"*.pyc",
"*.rdb",
"*.sqlite",
"*.sublime-workspace",
"*.ttf",
"*.woff",
"*.woff2",
"*.zip",
],
Just modify this to your needs, and then you will not see this in your project folders in Sublime.
Toggle
Maybe you just want to turn it off or on for the current file?
Try Sublime Command Palette using CTRL OR Command + Shift + P
and type:
HexViewer: Toggle Hex View
and press Enter or Return then the file will switch between HEX and TEXT.
Extra
If you don't want any-file to be converted to HEX then please use #steven-teo's answer.
If you want to learn more about the HEX Viewer you can see the Code Here & Documentation Here.
**Note: Keys vary for the Sublime Command Palette more info on that.