ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Console Wrap

by David Bekoyan ST2/ST3

This plugin helps you to work easily with log statements

Details

Installs

  • Total 12K
  • Win 6K
  • OS X 4K
  • Linux 2K
May 26 May 25 May 24 May 23 May 22 May 21 May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5 May 4 May 3 May 2 May 1 Apr 30 Apr 29 Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11
Windows 17 12 19 27 29 14 11 26 30 27 42 39 19 19 28 16 9 11 13 12 9 10 22 23 22 10 16 22 44 35 35 19 8 5 10 14 29 24 22 16 9 11 17 10 16 11
OS X 9 10 9 18 14 3 4 17 13 26 37 47 13 8 23 14 12 11 8 2 7 4 7 19 12 16 17 20 33 29 30 13 10 5 4 14 4 7 9 22 7 2 6 9 6 5
Linux 7 18 6 12 10 4 2 4 10 8 18 18 6 6 11 8 7 6 10 4 4 9 9 10 11 7 4 3 9 12 13 4 4 6 2 4 5 7 10 9 11 1 1 8 4 4

Readme

Source
raw.​githubusercontent.​com

Console Wrap

This plugin helps you easily create (comment, remove, show all) log statements (console.log, print etc.)

It places selected variable in log statement like console.log(“variable”, variable);

This is not a snippet.

Supported languages

  • Javascript
  • Python
  • Php

Usage

First you need to select a variable (or put cursor on it) and press "ctrl+shift+q". The log line will appear on the next line. Press "ctrl+shift+q" again to change wrapping (info,warn etc.)

You can Also remove, comment or remove commented log statements from your selsection or from all document you can find that functionality in context menu (right click) or Command Palette (command+shift+p on OS X, control+shift+p on Linux/Windows).

Screenshots

Javascript
Javascript
Python
Python
Php
Php
All Logs
All Logs

Key Binding

The default key binding is "ctrl+shift+q" and "ctrl+shift+alt+q" (insert before selection).

{ 
    "keys": ["ctrl+shift+q"], 
    "command": "console_wrap",
    "args": {"insert_before": false}
},
{ 
    "keys": ["ctrl+shift+alt+q"], 
    "command": "console_wrap",
    "args": {"insert_before": true}
}

Commands

{
    "caption": "Console Wrap: Create logs",
    "command": "console_wrap"
}, {
    "caption": "Console Wrap: Remove logs",
    "command": "console_action",
    "args": {"action": "remove"}
}, {
    "caption": "Console Wrap: Remove Commented logs",
    "command": "console_action",
    "args": {"action": "remove_commented"}
}, {
    "caption": "Console Wrap: Comment logs",
    "command": "console_action",
    "args": {"action": "comment"}
}, {
    "caption": "Console Wrap: Show all logs",
    "command": "console_action",
    "args": {"action": "show_quick_nav"}
}

Settings

{
    "js": {
        "consoleStr"   : "{title}, {variable}", // "{title}, tmpVal = {variable}" to assigne value to temporary parameter output: console.log('title', tmpVal = variable);
        "consoleFunc"  : ["console", "log"],    // You can change default log statement for example ["logger", "info"] output: logger.info('title', variable);
        "single_quotes": false,                 // If true output: console.log('title', variable);
        "semicolon"    : true,                  // If false, will not add semicolon at end of line
        "log_types"    : ["log", "info", "warn", "error"]
    },
    "py": {
        "consoleStr"   : "{title}, {variable}",
        "consoleFunc"  : ["print"],
        "single_quotes": false
    },
    "php": {
        "consoleFunc"  : ["print_r"],   // var_dump or if you have custom logger ["$logger", "debug"] output: $logger->debug($variable);
        "preTag"       : true,          // Put log in pre tag like echo '<pre>'; print_r($variable); echo '</pre>';
        "dieAfterLog"  : false          // echo '<pre>'; print_r($variable); echo '</pre>'; die();
    },
    "fileTypeMap" : {                   // Maps file type to wrapper. For example "text.html.vue": "js" means use js wrapper in vue js files
        "text.html.vue"  : "js",        // php,python,js is included by dafault ("embedding.php": "php", "source.js": "js", "source.python": "py")
        "source.ts"      : "js",
        "source.tsx"     : "js",
        "source.coffee"  : "js",
        "text.html.basic": "js",
        "text.html.blade": "js",
        "text.html.twig" : "js"
    }
}

How to install

With Package Control:

  1. Run “Package Control: Install Package” command, find and install Console Wrap plugin.
  2. Restart Sublime Text editor (if required)

Manually:

  1. Clone or download git repo into your packages folder (in Sublime Text, find Browse Packages… menu item to open this folder)
  2. Restart Sublime Text editor (if required)