Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 120 lines (101 sloc) 4.497 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
*sideways.txt* Move an item in a delimiter-separated list left or right

==============================================================================
CONTENTS *sideways* *sideways-contents*

    Installation............................: |sideways-installation|
    Usage...................................: |sideways-usage|
    Issues..................................: |sideways-issues|


==============================================================================
INSTALLATION *sideways-installation*

There are several ways to install the plugin. The recommended one is by using
Tim Pope's pathogen (http://www.vim.org/scripts/script.php?script_id=2332). In
that case, you can clone the plugin's git repository like so:
>
    git clone git://github.com/AndrewRadev/sideways.vim.git ~/.vim/bundle/sideways
<
If your vim configuration is under git version control, you could also set up
the repository as a submodule, which would allow you to update more easily.
The command is (provided you're in ~/.vim):
>
    git submodule add git://github.com/AndrewRadev/sideways.vim.git bundle/sideways
<

Another way is to simply copy all the essential directories inside the ~/.vim
directory: plugin, autoload, doc.

==============================================================================
USAGE *sideways-usage* *SidewaysLeft* *SidewaysRight*

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]
<
If you experiment with this example, you'll find that you can move the entire
second list around, as long as the cursor is on one of the inner brackets. The
plugin takes into consideration nested structures.

It works for lists in CSS declarations:
>
    border-radius: 20px 0 0 20px;
<
Also for single-line CSS declarations:
>
    a { color: #fff; background: blue; text-decoration: underline; }
<
And, it also works for cucumber tables:
>
    Examples:
      | input_1 | input_2 | button | output |
      | 20 | 30 | add | 50 |
      | 2 | 5 | add | 7 |
      | 0 | 40 | add | 40 |
<

It's highly recommended 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.

Bonus functionality: ~

The plugin's machinery makes it easy to implement an "argument" text object.
There are two mappings provided:
>
    <Plug>SidewaysArgumentTextobjA
    <Plug>SidewaysArgumentTextobjI
<
These are the outer and inner text objects, respectively. To use them, you
need to create mappings in your configuration files. Something like this:
>
    omap aa <Plug>SidewaysArgumentTextobjA
    xmap aa <Plug>SidewaysArgumentTextobjA
    omap ia <Plug>SidewaysArgumentTextobjI
    xmap ia <Plug>SidewaysArgumentTextobjI
<
This will map the "a" text object to operate on an "argument". So, you can
perform `daa` to delete an argument, `cia` to change an argument, and so on.
See |text-objects| for more information.

==============================================================================
ISSUES *sideways-issues*

Any issues and suggestions are very welcome on the github bugtracker:
https://github.com/AndrewRadev/sideways.vim/issues


vim:tw=78:sw=4:ft=help:norl:
Something went wrong with that request. Please try again.