Coder Social home page Coder Social logo

math2001 / foldfunctions Goto Github PK

View Code? Open in Web Editor NEW
12.0 4.0 0.0 292 KB

Sublime Text plugin to fold functions. And it supports functions with arguments on more than one line!

License: MIT License

Python 100.00%
sublime-text plugin python fold

foldfunctions's Introduction

FoldFunctions

This package folds every functions in the current file, so that you can have a global view of it, and then unfold a few, so that you don't have to scroll a lot, skipping over the functions you're not interested in at the moment.

For now, the following language are supported:

  • Python โค๏ธ
  • JavaScript

The good part is that it supports arguments on multiple lines, like so (in this case, it's python):

def my_function(argument_number_one, argument_number_two,
                argument_number_three):
    print('It works!!')

    for i in range(10):
        print('It really does!')

Example of folding with this package - FoldFunctions - through the command palette of Sublime Text

Installation

Because it is not available on package control for now, you have to add this repo "manually" to your list.

Using package control

  1. Open up the command palette (ctrl+shift+p), and find Package Control: Add Repository. Then enter the URL of this repo: https://github.com/math2001/FoldFunctions in the input field.
  2. Open up the command palette again and find Package Control: Install Package, and just search for FoldFunctions. (just a normal install)

Using the command line

cd "%APPDATA%\Sublime Text 3\Packages"             # on window
cd ~/Library/Application\ Support/Sublime\ Text\ 3 # on mac
cd ~/.config/sublime-text-3                        # on linux

git clone "https://github.com/math2001/FoldFunctions"

Which solution do I choose?

It depends of your needs:

  • If you intend to just use FoldFunctions, then pick the first solution (Package Control), you'll get automatic update.
  • On the opposite side, if you want to tweak it, use the second solution. Note that, to get updates, you'll have to git pull

Usage

The command is accessible from the command palette.

  • ctrl+shift+p
  • Search for Fold Functions
  • hit enter

Note: The caption will be the same, whichever supported language file you are editing, but the actual command will change. ๐Ÿ˜‰

Adding a key binding

It's up to you, but I prefer to have this command bound to this command, in my case, alt+f. So, here's what I've done:

{
    "keys": ["alt+f"],
    "command": "fold_python_functions",
    "context": [
        {"key": "selector", "operand": "source.python"}
    ]
},
{
    "keys": ["alt+f"],
    "command": "fold_javascript_functions",
    "context": [
        {"key": "selector", "operand": "source.js"}
    ]
}

foldfunctions's People

Contributors

math2001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

foldfunctions's Issues

fold nested functions

hi there, is there any chance for the plugin to check if there are nested functions, and if yes then fold them and leave the parent expanded ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.