I would like to make it so that whenever I open a file in Sublime it will automatically do "Fold Level 2" Coding which is command shortcut Ctrl-K,Ctrl-2 (or CMD-K, CMD-2). I use both mac and pc.
I don't want to enter that shortcut everytime, instead I would like Sublime to automatically run that on opening a file. Please let me know if there a way to do that.
You can use the shortcut key Ctrl+Shift+Q on Windows and Cmd+Shift+Q for Mac, to play a macro recorded by the user in Sublime Text.
To run code in Sublime Text, go to Tools > Build System, and select the language for your code (Sublime comes with support for various languages like Python, Ruby, Bash, and more). Next, press Cmd+B on Mac or Ctrl+B on Windows to run your code.
To run the code, press Command B or go to Tools -> Build. As you can see, my Sublime Text is running Python 2.7. To change this to Python 3.7, we have to add a “Build System.”
I think that the best solution to your problem is Buffer Scroll plugin. It remembers and restores a lot of things, folding included.
If you don't want to install that plugin, you can create your own:
Tools / New Plugin...
import sublime, sublime_plugin
class Folding(sublime_plugin.EventListener):
def on_load(self, view):
view.run_command("fold_by_level", {"level": 2})
User
directory with the filename you prefer.This will set folding level to 2, for every file you open.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With