Code Monkey home page Code Monkey logo

hungrybackspace's Introduction

Hungry Backspace for Sublime Text

Overview

This small plugin brings to Sublime Text the "hungry backspace" feature from IntelliJ. The hungry backspace retains the scope (indentation) when the backspace key is pressed on an empty line.

Live demo

Warning

This plugin is NOT meant to replace backspace entirely, it is meant to be used in conjunction with the original backspace function which is now accessed by Shift+Backspace

(!) USE THE DEFAULT BACKSPACE WHENEVER YOU NEED IT USING SHIFT+BACKSPACE

Version

1.1.4

What's new

New features demo

Added 3 new features based on IntelliJ's smart backspace, of which two are experimental and one is enabled by default.

  • [Experimental] When you press backspace with your cursor at line start if the indentation level of the current line is wrong it is reindented Options: "enabled"/ "disabled" / "forced"

    "right_to_left_backspacing" : true

  • If you are on line start and the upper line is empty the current line gets moved one up

    "consume_above_line": true

  • [Experimental] If you are on line start and press backspace and the upper line is not empty the current lines contents get moved up Options: "enabled"/ "disabled" / "forced"

    "backspace_line_content_move": "enabled"

Installation

By Package Control

  1. Download & Install Sublime Text 3 (https://www.sublimetext.com/3)
  2. Go to the menu Tools -> Install Package Control, then, wait few seconds until the installation finishes up
  3. Now, Go to the menu Preferences -> Package Control
  4. Type Add Channel on the opened quick panel and press Enter
  5. Then, input the following address and press Enter
    https://raw.githubusercontent.com/evandrocoan/StudioChannel/master/channel.json
    
  6. Go to the menu Tools -> Command Palette... (Ctrl+Shift+P)
  7. Type Preferences: Package Control Settings โ€“ User on the opened quick panel and press Enter
  8. Then, find the following setting on your Package Control.sublime-settings file:
    "channels":
    [
        "https://packagecontrol.io/channel_v3.json",
        "https://raw.githubusercontent.com/evandrocoan/StudioChannel/master/channel.json",
    ],
  9. And, change it to the following, i.e., put the https://raw.githubusercontent... line as first:
    "channels":
    [
        "https://raw.githubusercontent.com/evandrocoan/StudioChannel/master/channel.json",
        "https://packagecontrol.io/channel_v3.json",
    ],
    • The https://raw.githubusercontent... line must to be added before the https://packagecontrol.io... one, otherwise, you will not install this forked version of the package, but the original available on the Package Control default channel https://packagecontrol.io...
  10. Now, go to the menu Preferences -> Package Control
  11. Type Install Package on the opened quick panel and press Enter
  12. Then, search for HungryBackspace and press Enter
  13. Try it by pressing backspace on some empty lines!
  14. You can change the key bindings by going to Preferences then Package Settings then Hungry Backspace, and select they keymap option

See also:

  1. ITE - Integrated Toolset Environment
  2. Package control docs for details.

Key bindings

By default this plugin overrides your backspace with the "hungry" one however, as mentioned previously the plugin is meant to be used in conjunction with the default backspace which is now accessible via SHIFT+BACKSPACE. You can flip between space and shift-backspace at any time by pressing CTRL+.(dot)

[
  // the hungry backspace
  { "keys": ["backspace"], "command": "hungry_backspace" },
  // the default backspace
  { "keys": ["shift+backspace"], "command": "default_backspace"},
  // flipping the hungry and default backspace actions
  { "keys": ["ctrl+."], "command": "flip_hungry_backspace_key_bindings"}
]

Settings

{
  // enable/disable plugin
  "enabled": true,
  // filetypes with these extensions don't have hungry backspacing
  "excluded_filetypes": ["hs", "py"],
  // controls whether the default/hungry backspace bindings should be flipped
  "flipped_key_bindings": false,
  // when the upper line is empty but contains some indentation a backspace
  // causes the upper line to obtain this lines indentation
  "force_indent_at_upper_level" : true,
  // [Experimental] When you press backspace with your cursor at line start
  // if the indentation level of the current line is wrong it is reindented
  // Options: "enabled"/ "disabled" / "forced"
  "right_to_left_backspacing" : "disabled",
  // If you are on line start and the upper line is empty
  // the current line gets moved one up
  "consume_above_line": true,
  // [Experimental] If you are on line start and press backspace and the upper line is not empty
  // the current lines contents get moved up
  // Options: "enabled"/ "disabled" / "forced"
  "backspace_line_content_move": "disabled"
}

License

Copyright (c) 2016 xdrop

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

hungrybackspace's People

Contributors

xdrop avatar evandrocoan avatar

Stargazers

Brian avatar  avatar

Watchers

James Cloos avatar  avatar

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.