How do I activate the Zen coding key bindings in Sublime Text 2? - sublimetext

I just downloaded the Zen coding package for Sublime Text 2, but I can't figure out how to activate it.
I already have it in Netbeans, and here you just have to press CTR+ALT+N, but this doesn't work in the Sublime editor.
Google didn't yield any results, so I'm asking here.
Can someone tell me how to activate the Zen coding function?

press Ctrl+Alt+Enter and you'll get a text input box at the bottom of the screen, titled: Enter Koan:. as you type the zen expression into the box it will simultaneously unfold on the screen.
Alternatively, you can type the zen expression in the editor and press tab to expand it. Be sure not to leave any spaces inside the expression or after it.

I have been using Sublime Text 2 beta, build 2139 on Windows (but I'm also pretty sure this should work on Mac OS and Linux too) and here's how I got it to work:
After installing Sublime Text 2 itself, install Package Control
for Sublime Text 2. This is an add-on that allows you to easily
manage another add-ons.
I couldn't get the first installation option to work so I went for
the manual method. On my installation there was no folder called
"Installed packages", instead I've used "Pristine Packages" folder
which seemed to contain other, already installed extensions.
Restart Sublime Text 2
With Package Control installed open Sublime Text 2 editor and choose Preferences -> Package Control -> Package Control : Install Package from the menu. Hit "Enter" and there should be a list of packages available for installation displayed on the screen. Start typing "Zen" and Zen-Coding will be presented. When selected hit "Enter" again, status bar on the bottom of the screen will be showing installation progress.
When it's done - restart Sublime Text 2 one last time. Now, you can expand Zen-Coding abbreviations with 'ctrl+space' or 'tab'.
Remember it will only work in the saved file, with extension "html". (in particular - it won't work on the new document you've just created).
I hope this helps

To expand your zencoding, just press TAB. However, for a full list of all the keybindings, look in your Zencoding folder for a file called "Default (NAME_OF_YOUR_OPERATING_SYSTEM).sublime-keymaps". To get to the package, go to "Preferences > Browse Packages > zencoding".

Ctrl + Opt (Alt on a PC) + Enter. Check out the video.

See this post : Zen coding downloading trouble
and my comments for detailed instructions.
Also, after an upgrade, just replace the folder with the original one from
http://dl.dropbox.com/u/1292831/ZenCoding.zip
Good Luck ..

Download this one; https://github.com/sergeche/zencoding-sublime
It works on SublimeText2 2.0.1 build 2217 windows.

After install Emmet package, remember to restart sublime editor and save a file first to try it!. I thought it wasn't working after install, but it just needs a saved file to work on it.

Related

How to force folder refresh in Sublime, when "Project > refresh" doesn't work?

Especially when using an sftp drive (but this problem is also an issue with local drives, although thankfully not as frequent), the folders in the sidebar just keep spinning and spinning, and the "Open Anything" dialog therefore has no files to choose from.
"Project > Refresh folders" does not work in most cases.
I've resorted to restarting Sublime manually, which works most of the time, but it's getting to be a pain to have to do this every other time I switch projects.
Is there any better way to "force" the folders to refresh?
This problem is the reason I asked this question:
How to save project state before exiting in ST3 on Windows?
The SublimeRestart plugin doesn't work on Windows until this project-state-saving problem is solved. However, even if it did work perfectly, it would still only be a workaround for this really annoying non-refreshing-folders issue.
My workaround on Windows, FYI: After loading a project, when the folders don't refresh (don't load even the first time), I have ctrl+f10 bound to "File > Exit", and f10 configured into the shortcut that I launch Sublime Text with. So two reasonably-quick (although additional!) button presses.
Open Sublime Text.
Select Preferences from the top menu and click Key Bindings – User. Here you will see a JSON file that should contain an array of objects (initially the array is empty). Every object will represent a shortcut.
Add the following (new shortcut object) entry into the array (between the brackets):
{
"keys" : ["f5"],
"command" : "refresh_folder_list"
}
You should be able to refresh the folders with F5.
Try to Install this package:
https://packagecontrol.io/packages/SideBarEnhancements
Open the package folder. Main menu -> Preferences -> Package Control: -> Package Control: Install Package
Search the keyword: Side​Bar​Enhancements
Enjoy it
After you install this plugin, you will see the refresh button in your sidebar option:
I have added this myself the other day. I constantly work in an environment where files in the project are changing before I can see them.
Goto 'Preferences' menu -> 'Key Bindings' -> 'User' which will open a JSON file, add below code, save and close that file.
{ "keys": ["ctrl+f5"], "command": "refresh_folder_list" }
It will work like charm 100%. Thanks for asking this question.
This isn't going to be a very useful answer but it documents some early behaviour in Sublime Text that would solve your problem, assuming you need no later features from Sublime Text 2/3 (a big assumption indeed).
Sublime Text 1 had the handy feature in the folder context menu to "Refresh folder". This cause an immediate indexing of only the specified directory (and subdirectories) which was a boon when using networked drives over high-latency connections.
This was deprecated in Sublime Text 2.
Version 1 is available here or by direct download here. It's not clear that these will be available indefinitely though, so this isn't necessarily a long-term solution.

Customising the syntax colour in Sublime Text 3

I'm in the process of creating my own syntax colour theme for Sublime Text 3. I've done quite a lot but I want to copy most of the JavaScript colour syntax from the default 'Cobalt' theme that comes with ST3 (and possibly mix-and-match from other themes). I can't seem to find the Cobalt theme anywhere on my Mac?
Any ideas on where this might be?
Instead of navigating through /Applications, the easiest way of accessing built-in packages in Sublime Text 3 is to use #skuroda's excellent PackageResourceViewer plugin, available through Package Control. Once installed, restart Sublime and hit ⌘ShiftP to open the Command Palette. Type prv to bring up the PackageResourceViewer options, and select Open Resource. Scroll down to Color Scheme - Default, hit Enter, then scroll down to select Cobalt.tmTheme and hit Enter. You can now hit Esc to get rid of the menu, and start looking through the theme file for the bits you want to copy.
Good luck!
In Sublime Text installation directory, if I'm not mistaken, that's /Applications/ on OS X, there's a Packages directory, which contains a package file Color Scheme - Default.sublime-package which contains all the default color schemes.
.sublime-package is a simple zip file with modified extension, so you may simply copy it somewhere in your home directory, extract it and browse through the Cobalt.tmTheme file.
P.S. If you have trouble opening it with OS X archive manager, you may simply rename it:
mv name.sublime-package name.zip
But as far as I remember, it could be done simply like (correct me here if I'm wrong)
unzip name.sublime-package -d somedir

Zen Coding Plugin Install for Sublime Text 2 portable in Window

I have already downloaded portable software for sublime Text editor. But, I don't know how to install zen coding in that portable. When I google about that issues, I found some installation guide line but not on portable sublime text editor. Please, anyone can help me? Thank you all
To install “Package Control,” open Sublime and press Control + `.
import urllib2,os;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();os.makedirs(ipp) if not os.path.exists(ipp) else None;open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read())
Lastly, restart Sublime Text, and browse to Preferences -> Package Settings. If the installation was successful, you’ll now see a Package Control item in that list.

Hotkey for commenting ruby code in Aptana Studio 3 not Working with german keyboard

In Aptana Studio 3 (latest version and all previous versions of 3) I am not able to comment lines via keyboard shortcuts. I have a german keyboard layout.
The default shortcut is CTRL + /, but this doesn't work. Even setting the shortcut in Preferences/General/Keys doesn't work. The command is called Python Toggle Comment.
Using the Commands menu and use Source -> Comments -> Comment Line / Selection comments the lines correctly. In this menu I can also see the hotkey CTRL + / behind the menu entry.
It would increase the speed of writing and testing code, if I could use the hotkey. How can I achieve this?
You can try pulling down a copy of the Source ruble and edit the keybinding to one that works for you. Commands > Source > Edit this bundle. It'll try to do a git clone of the bundle into your "Documents/Aptana Rubles/source.ruble" folder. Then you can edit commands/toggle_comment.rb and change the binding to what works for you.

Code Formatting In Xcode

Is there anyway to format the code in Xcode like you can do in Eclipse or Netbenas. I have not found any option in menu, is there any hot key for this or its simply not in Xcode?
In Xcode 4, it's been moved to Editor > Structure > Re-Indent command (and has a default shortcut of CTRL+I ).
Select some text and then: Edit->Format->Re-Indent
You can bind this to a hotkey in the preferences.
Well, first of all welcome to 2021. I know it's a very old question but still people like me visit this and for those people, I'm putting out multiple available solutions in one answer that worked for me after 2 hours of research and testing.
Re-Indent
As everyone else is suggesting, it's one of the default solution if you just want to re-indent the lines of code:
Goto: Editor -> Structure -> Re-Indent or use shortcut control + I
Using Xcode Extensions
There are 2 extensions I found and used which works charmingly for me.
1) SwiftFormat: mentioning the steps to install the xcode extension here from the readme.
Like the command-line tool, you can install the SwiftFormat for Xcode
extension application via Homebrew. Assuming you already have Homebrew
installed, type:
$ brew install --cask swiftformat-for-xcode
open the SwiftFormat for Xcode.app that you just installed. there you can change the rules of formatting.
After that, open the system preference -> extensions -> xcode source editor and mark the checkbox for SwiftFormat.
Restart the Xcode
Voila! You're good to go. you can use three options. format selected code, format entire file OR just lint file.
2) Swimat: (it is already mentioned in one of the answer here by #Guy Daher) steps to install from readme
Install via homebrew-cask
Homebrew latest version
brew install --cask swimat
Similar to above extension installation, open the Swimat.app if it does not open then try to sove it from system preferences -> security & privacy -> open swimat app
after opening, click on install in ./bin folder to make it work globally (not sure about this step but I just did it)
Restart Xcode
now you can goto editor -> swimat -> format
Bingo! You're good to go.
Additional uninvited help
You can simply set the keybinding to use any of this command. i.e. I've set the android studio default command to reformat the code as option + command + L
ps If anyone else found a better extension, please let me know in comment, I'll add it to the list.
Other than re-indentation (Edit > Format > Re-Indent), not really. However, Xcode does have support for scripts (the menu to the right of the Window menu), so you could conceivably write a script that formats your code how you like it.
Edit: here are some links that touch on this subject:
http://hackertoys.com/2008/09/18/adding-a-code-beautifier-script-to-xcode (dead link)
http://8020world.com/jcmendez/2006/11/geeky-stuff/software/adding-a-script-menu-to-xcode-to-reformat-code-using-astyle (dead link)
Here are the shortcuts, to format the code in Xcode
1.Format entire code (entire class/controller)
select the entire code and press ⌘+| on mac to format your code.
2.Format particular block of code
select the code and press
⌘+] for right move and ⌘+[ for left move
Note : as per #JavierGiovannini sugesstion you can do using Editor Menu option
3.Select code --> Go to Editor --> Structure --> Re-Indent
My personal favorite code formatter is Uncrustify.
It has many, many options, so I also suggest you download UniversalIndentGUI, a GUI to help set Uncrustify's behavior to your liking.
XCode 8 Extensions
Another option is to use an extension like Swimat. Does the job for me. However, the caveat is that it does not format on save due to the restrictive Xcode Extension APIs, but they're trying to find a workaround.
Not saying this is best approach, but for completeness, if you cut and then paste the code back in, Xcode will automatically format it for you.
In v.4 you can make some adjustments through xCode preferences...
Fix code indentation in Xcode
^-I (control - capital i)
: format the current line
⌘-A + ^-I
: format the whole code file
Try this solution: ⌘A [⌘K ⌘F]

Resources