Code Monkey home page Code Monkey logo

commentsawareenter's Introduction

Comments Aware Enter and Join Lines for Sublime Text 2/3

Hitting Enter in line comments will insert a proper indented comment marker for you. In its turn Ctrl+J (Cmd+J on OS X) joins comment lines removing comment markers and extraneous whitespace.

This plugin is for line comments only, so it doesn't work with block ones.

Thats cool, but can I use smth + Enter instead?

Sure, just add one of the following lines to your User Preferences:

{
    ...
    "linecomments_ctrl_enter": true,
    "linecomments_alt_enter": true,
    "linecomments_shift_enter": true,
    "linecomments_super_enter": true, // Stands for Cmd on Mac OS X
    ...
}

If any one of this options is used then plain Enter won't be captured, modified shortcut will be.

Labels and bullets

CommentAwareEnter will automatically create "-" bullet for you and autoindent after labels:

# TODO: Some thing,
#       other thing indented.
#           - nicely
#           - formatted list

To switch off label indent say this in your settings:

{
    ...
    "linecomments_label_indent": false,
    ...
}

commentsawareenter's People

Contributors

aron avatar jongretar avatar mwilliammyers avatar suor avatar tmichel avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

commentsawareenter's Issues

ValueError: too many values to unpack after hitting Enter on url

Traceback (most recent call last):
  File ".\sublime_plugin.py", line 362, in run_
  File ".\comments_aware_enter.py", line 30, in run
ValueError: too many values to unpack

Code to reproduce:

        //   "smartstrong": http://packages.python.org/Markdown/extensions/smart_strong.html
        //   "codehilite": http://packages.python.org/Markdown/extensions/code_hilite.html
        //   "metadata": http://packages.python.org/Markdown/extensions/meta_data.html
        //   "toc": http://packages.python.org/Markdown/extensions/toc.html

Hit Enter after 'http://' will raise that exception.

A better keymap?

I have this keymap in my settings

 {
   "keys": ["enter"],
   "args":{"contents":"\n$TM_COMMENT_START"},
   "command": "insert_snippet",
   "context": [
       {"key": "selector", "operator": "equal", "operand": "comment.line"},
       {"key": "selector", "operator": "not_equal", "operand": "text.tex"}
   ]
 }

is your plugin doing something more than this?
This keymap has the advantage that it picks up the comment symbol from ST's language definition instead of having to specify them separately in the plugin...

Enter doesn't work on comments at all

Like I said, enter won't work on comments at all, anywhere in any line of commenting the enter key is completely disabled it seems. I'm running on Windows 7 and have several other plugins installed.

this plugin doesn't work.

either use default enter nor XX+enter doesn't work.
And I tried to modify the source and failed.

How to use this plugin?

No PHP block comment

Hi, I checked out this plugin cause it seems like a cool idea.

I checked the source code, but I noticed PHP and JavaScript don't have their comment blocks defined. At least not at first look. I'm talking about this one:

/*

*/

And of course:

/**
 * 
 */

Did you just overlook this at development? Or is it already covered and I'm just not seeing it?

comment-block in php not working as expected

When i enter comment-block in php then it enter something like
/**
*
block code
*
*
/
While it should be something like
block code.png

Because this is the standard in php code block, specially in drupal.

Support arbitrary comment types, instead of special cases

This seems to support only a handful of comment types, and I don't see why. Instead of hardcoding a whitelist of "known" types, the plugin could look for a region scoped as punctuation.definition.comment on the same line to the left of the caret, and use the resulting string as the comment delimiter. This would work for arbitrary languages, and it would support multiple comment types per language, such as // and /// in Rust, as long as the syntax implementation scopes them appropriately.

Add modifier to enter key to make this optional

Since this is working in individual lines rather than block comments, I think the key binding should include a modifier key, so the regular case of a single line comment followed by enter is preserved.

I've had a quick look through the docs and it seems shift+enter or alt+enter might be ok if we check for any find or replace command running, and fail if that is the context.

With your experience, what do you think of this? I'm new to Sublime key bindings, but I quite like this function and would prefer it to be optional.

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.