Code Monkey home page Code Monkey logo

sideways.vim's Introduction

This is a mirror of http://www.vim.org/scripts/script.php?script_id=4171

Github project: https://github.com/AndrewRadev/sideways.vim

The plugin defines two commands, ":SidewaysLeft" and ":SidewaysRight", which move the item under the cursor left or right, where an "item" is defined by a delimiter. As an example:

    def function(one, two, three):
        pass

Placing the cursor on "two" and executing `:SidewaysLeft`, the "one" and "two" arguments will switch their places, resulting in this:

    def function(two, one, three):
        pass

In this case, the delimiter is a comma. The plugin currently works with various other cases and it's intended to make the process configurable. While this particular example is in python, this should work for arguments in many different languages that use round braces to denote function calls.

For ruby and eruby, it detects method calls without braces as well:

    link_to user_registration_path, 'Something'
    # changes to:
    link_to 'Something', user_registration_path

Apart from functions, it works for square-bracket lists in dynamic languages:

    list = [one, [two, four, five], three]

Notice that, if you experiment with this example, you'll find that you can move the entire second list around. The plugin takes into consideration nested structures.

Apart from functions, it works for lists in CSS declarations:

    border-radius: 20px 0 0 20px;

And, it also works for cucumber tables (see docs for better table formatting):

    Examples:
      | input_1 | input_2 | button | output |
      | 20      | 30      | add    | 50     |
      | 2       | 5       | add    | 7      |
      | 0       | 40      | add    | 40     |

It's highly suggested to map the two commands to convenient keys. For example, mapping them to <c-h> and <c-l> would look like this:

    nnoremap <c-h> :SidewaysLeft<cr>
    nnoremap <c-l> :SidewaysRight<cr>

The plugin is intended to be customizable, though at this point you'd need to look at the source to do this.

sideways.vim's People

Watchers

 avatar  avatar  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.