Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 144 lines (123 sloc) 5.295 kb
badb2c8 @AndrewRadev Version 0.1.0
AndrewRadev authored
1 *sideways.txt* Move an item in a delimiter-separated list left or right
2
1a0097a @AndrewRadev Version 0.0.1: Initial upload
AndrewRadev authored
3 ==============================================================================
4 CONTENTS *sideways* *sideways-contents*
5
6 Installation............................: |sideways-installation|
7 Usage...................................: |sideways-usage|
8 Issues..................................: |sideways-issues|
9
10
11 ==============================================================================
12 INSTALLATION *sideways-installation*
13
14 There are several ways to install the plugin. The recommended one is by using
15 Tim Pope's pathogen (http://www.vim.org/scripts/script.php?script_id=2332). In
16 that case, you can clone the plugin's git repository like so:
17 >
18 git clone git://github.com/AndrewRadev/sideways.vim.git ~/.vim/bundle/sideways
19 <
20 If your vim configuration is under git version control, you could also set up
21 the repository as a submodule, which would allow you to update more easily.
22 The command is (provided you're in ~/.vim):
23 >
24 git submodule add git://github.com/AndrewRadev/sideways.vim.git bundle/sideways
25 <
26
27 Another way is to simply copy all the essential directories inside the ~/.vim
ec2f8ed @AndrewRadev Version 0.0.2
AndrewRadev authored
28 directory: plugin, autoload, doc.
1a0097a @AndrewRadev Version 0.0.1: Initial upload
AndrewRadev authored
29
30 ==============================================================================
aa77be1 @AndrewRadev Version 0.2.0
AndrewRadev authored
31 USAGE *sideways-usage*
32 *SidewaysLeft*
33 *SidewaysRight*
1a0097a @AndrewRadev Version 0.0.1: Initial upload
AndrewRadev authored
34
35 The plugin defines two commands, |:SidewaysLeft| and |:SidewaysRight|, which
36 move the item under the cursor left or right, where an "item" is defined by a
37 delimiter. As an example:
38 >
39 def function(one, two, three):
40 pass
41 <
42 Placing the cursor on "two" and executing |:SidewaysLeft|, the "one" and "two"
43 arguments will switch their places, resulting in this:
44 >
45 def function(two, one, three):
46 pass
47 <
48 In this case, the delimiter is a comma. The plugin currently works with
49 various other cases and it's intended to make the process configurable. While
50 this particular example is in python, this should work for arguments in many
51 different languages that use round braces to denote function calls.
52
badb2c8 @AndrewRadev Version 0.1.0
AndrewRadev authored
53 For ruby and eruby, it detects method calls without braces as well:
54 >
55 link_to user_registration_path, 'Something'
56 # changes to:
57 link_to 'Something', user_registration_path
58 <
1a0097a @AndrewRadev Version 0.0.1: Initial upload
AndrewRadev authored
59 Apart from functions, it works for square-bracket lists in dynamic languages:
60 >
61 list = [one, [two, four, five], three]
62 <
badb2c8 @AndrewRadev Version 0.1.0
AndrewRadev authored
63 If you experiment with this example, you'll find that you can move the entire
64 second list around, as long as the cursor is on one of the inner brackets. The
65 plugin takes into consideration nested structures.
1a0097a @AndrewRadev Version 0.0.1: Initial upload
AndrewRadev authored
66
aa77be1 @AndrewRadev Version 0.2.0
AndrewRadev authored
67 It's highly recommended to map the two main commands to convenient keys. For
68 example, mapping them to <c-h> and <c-l> would look like this:
69 >
70 nnoremap <c-h> :SidewaysLeft<cr>
71 nnoremap <c-l> :SidewaysRight<cr>
72 <
73 Other things that sideways works for:
74
75 Lists in CSS declarations:
1a0097a @AndrewRadev Version 0.0.1: Initial upload
AndrewRadev authored
76 >
77 border-radius: 20px 0 0 20px;
78 <
aa77be1 @AndrewRadev Version 0.2.0
AndrewRadev authored
79 Single-line CSS declarations:
ec2f8ed @AndrewRadev Version 0.0.2
AndrewRadev authored
80 >
81 a { color: #fff; background: blue; text-decoration: underline; }
82 <
aa77be1 @AndrewRadev Version 0.2.0
AndrewRadev authored
83 HTML attributes:
84 >
85 <input name="one" id="two" class="three" />
86 <
87 Cucumber tables:
1a0097a @AndrewRadev Version 0.0.1: Initial upload
AndrewRadev authored
88 >
89 Examples:
90 | input_1 | input_2 | button | output |
91 | 20 | 30 | add | 50 |
92 | 2 | 5 | add | 7 |
93 | 0 | 40 | add | 40 |
94 <
aa77be1 @AndrewRadev Version 0.2.0
AndrewRadev authored
95 Go lists:
1a0097a @AndrewRadev Version 0.0.1: Initial upload
AndrewRadev authored
96 >
aa77be1 @AndrewRadev Version 0.2.0
AndrewRadev authored
97 []string{"One", "Two", "Three"}
1a0097a @AndrewRadev Version 0.0.1: Initial upload
AndrewRadev authored
98 <
aa77be1 @AndrewRadev Version 0.2.0
AndrewRadev authored
99 Javascript-like objects:
100 >
101 dict = {one: 1, two: 2, three: 3}
102 <
103 The plugin is customizable, though at this point you'd need to look at the
104 source to do this.
1a0097a @AndrewRadev Version 0.0.1: Initial upload
AndrewRadev authored
105
aa77be1 @AndrewRadev Version 0.2.0
AndrewRadev authored
106 *SidewaysJumpLeft*
107 *SidewaysJumpRight*
badb2c8 @AndrewRadev Version 0.1.0
AndrewRadev authored
108
109 Bonus functionality: ~
110
111 The plugin's machinery makes it easy to implement an "argument" text object.
112 There are two mappings provided:
113 >
114 <Plug>SidewaysArgumentTextobjA
115 <Plug>SidewaysArgumentTextobjI
116 <
117 These are the outer and inner text objects, respectively. To use them, you
118 need to create mappings in your configuration files. Something like this:
119 >
120 omap aa <Plug>SidewaysArgumentTextobjA
121 xmap aa <Plug>SidewaysArgumentTextobjA
122 omap ia <Plug>SidewaysArgumentTextobjI
123 xmap ia <Plug>SidewaysArgumentTextobjI
124 <
125 This will map the "a" text object to operate on an "argument". So, you can
126 perform `daa` to delete an argument, `cia` to change an argument, and so on.
127 See |text-objects| for more information.
1a0097a @AndrewRadev Version 0.0.1: Initial upload
AndrewRadev authored
128
aa77be1 @AndrewRadev Version 0.2.0
AndrewRadev authored
129 The plugin also provides the commands |:SidewaysJumpLeft| and
130 |:SidewaysJumpRight|, which move the cursor left and right by items.
131
132 Also, a useful plugin to use alongside sideways is `fieldtrip`
133 (https://github.com/tek/vim-fieldtrip). This defines a submode
134 (https://github.com/kana/vim-submode) for sideways.vim.
135
1a0097a @AndrewRadev Version 0.0.1: Initial upload
AndrewRadev authored
136 ==============================================================================
137 ISSUES *sideways-issues*
138
139 Any issues and suggestions are very welcome on the github bugtracker:
140 https://github.com/AndrewRadev/sideways.vim/issues
141
142
143 vim:tw=78:sw=4:ft=help:norl:
Something went wrong with that request. Please try again.