Commits

Nicola Paolucci committed 55e5264

Squashed '.vim/bundle/triglav-vim-visual-increment/' content from commit 760abfc

git-subtree-dir: .vim/bundle/triglav-vim-visual-increment
git-subtree-split: 760abfc1a4756d4a140b422084a2cbb8788638b4

  • Participants

Comments (0)

Files changed (3)

+# visual-increment.vim
+
+## Description
+
+This plugin adds a simple functionality that creates increasing and decreasing
+number or letter sequences on multiple lines via visual mode.
+
+Simply select the desired columns via visual mode and use standard vim mapping
+for adding or subtracting.
+
+## Usage
+
+1. For example, we have an array of 5 items and we would like to define them:
+
+        example[0] = 'e';
+        example[0] = 'e';
+        example[0] = 'e';
+        example[0] = 'e';
+        example[0] = 'e';
+
+2. Press `<C-V>` at the first index and select all the index columns on multiple
+   lines, press `<C-A>`:
+
+        example[0] = 'e';
+        example[1] = 'e';
+        example[2] = 'e';
+        example[3] = 'e';
+        example[4] = 'e';
+
+### Increment steps
+
+You can use `[count]` to define the "increment step" between each line. For
+example, by pressing `5<C-A>` at the index column, you will get:
+
+    example[5] = 'e';
+    example[10] = 'e';
+    example[15] = 'e';
+    example[20] = 'e';
+    example[25] = 'e';
+
+### Letter sequence
+
+You need to add the following line to your `.vimrc` file:
+
+    set nrformats=alpha
+
+The letter sequence is then created via `<C-X>` as expected:
+
+    example[0] = 'e';
+    example[1] = 'd';
+    example[2] = 'c';
+    example[3] = 'b';
+    example[4] = 'a';
+
+### Octal & Hex sequences
+
+To create octal or hexadecimal sequences, simply add the respective option to
+the `nrformats`:
+
+    set nrformats=aplha,octal,hex
+
+Octal numbers start with a zero:
+
+    example[0] = 01;
+    example[1] = 06;
+    example[2] = 013;
+    example[3] = 020;
+    example[4] = 025;
+
+Hexadecimal numbers start with `0x` or `0X`:
+
+    example[0] = 0x1;
+    example[1] = 0x6;
+    example[2] = 0xb;
+    example[3] = 0x10;
+    example[4] = 0x15;
+
+## License
+
+visual-increment is released under the MIT license:
+
+Copyright 2011 Matej Svec. All rights reserved.
+
+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.
+

File doc/visual-increment.txt

+*visual-increment.txt* create increasing sequence of numbers via visual mode
+
+visual-increment                                            *visual-increment*
+Last Change: April 21, 2011
+
+Description                   |visual-increment-description|
+Usage                         |visual-increment-usage|
+Increment Steps               |visual-increment-steps|
+Letter Sequence               |visual-increment-letter|
+Octal and Hex Sequences       |visual-increment-octal| |visual-increment-hex|
+Contact                       |visual-increment-contact|
+License                       |visual-increment-license|
+
+For Vim version 7.3 or later.
+This plugin only works if 'compatible' is not set.
+
+==============================================================================
+DESCRIPTION                                     *visual-increment-description*
+
+This plugin adds a simple functionality that creates increasing and decreasing
+number or letter sequences on multiple lines via visual mode.
+
+Simply select the desired columns via visual mode and use standard vim mapping
+for adding or subtracting.
+
+==============================================================================
+USAGE                                                 *visual-increment-usage*
+
+1. For example, we have an array of 5 items and we would like to define them:
+
+        example[0] = 'e';
+        example[0] = 'e';
+        example[0] = 'e';
+        example[0] = 'e';
+        example[0] = 'e';
+
+2. Press <C-V> at the first index and select all the index columns on multiple
+   lines, press <C-A>
+
+        example[0] = 'e';
+        example[1] = 'e';
+        example[2] = 'e';
+        example[3] = 'e';
+        example[4] = 'e';
+
+==============================================================================
+INCREMENT STEPS                                       *visual-increment-steps*
+
+You can use [count] to define the "increment step" between each line. For
+example, by pressing 5<C-A> at the index column, you will get:
+
+        example[5] = 'e';
+        example[10] = 'e';
+        example[15] = 'e';
+        example[20] = 'e';
+        example[25] = 'e';
+
+==============================================================================
+LETTER SEQUENCE                                      *visual-increment-letter*
+
+You need to add the following line to your |.vimrc| file:
+
+        set nrformats=alpha
+
+The letter sequence is then created via <C-X> as expected:
+
+        example[0] = 'e';
+        example[1] = 'd';
+        example[2] = 'c';
+        example[3] = 'b';
+        example[4] = 'a';
+
+==============================================================================
+OCTAL AND HEX SEQUENCES        *visual-increment-octal* *visual-increment-hex*
+
+To create octal or hexadecimal sequences, simply add the respective option to
+the [nrformats]:
+
+        set nrformats=aplha,octal,hex
+
+Octal numbers start with a zero:
+
+        example[0] = 01;
+        example[1] = 06;
+        example[2] = 013;
+        example[3] = 020;
+        example[4] = 025;
+
+Hexadecimal numbers start with "0x" or "0X":
+
+        example[0] = 0x1;
+        example[1] = 0x6;
+        example[2] = 0xb;
+        example[3] = 0x10;
+        example[4] = 0x15;
+
+==============================================================================
+CONTACT                                             *visual-increment-contact*
+
+Triglav <trojhlav@gmail.com>                         *visual-increment-author*
+https://github.com/triglav/vim-visual-increment
+
+==============================================================================
+LICENSE                                             *visual-increment-license*
+
+visual-increment is released under the MIT license:
+
+Copyright 2011 Matej Svec. All rights reserved.
+
+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.
+
+==============================================================================
+
+vim:tw=78:ts=8:ft=help:norl:

File plugin/visual-increment.vim

+" visual-increment.vim - easily create increasing sequence of numbers or letters
+" via visual mode
+" Author: Triglav <trojhlav@gmail.com>
+" Home: https://github.com/triglav/vim-visual-increment
+
+" exit if the plugin is already loaded or disabled or when 'compatible' is set
+if (exists("g:loaded_visual_increment") && g:loaded_visual_increment) || &cp
+  finish
+endif
+let g:loaded_visual_increment = 1
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+" a:step - increment step, default 1
+" a:1 - default null, when set to any value, decrement instead
+function! s:doincrement(step, ...)
+  " visual block start
+  let start_column = col("'<")
+  let start_row = line("'<")
+  " visual block end, as well as the cursor position
+  let end_row = line("'>")
+  " when 2nd parameter is passed, we are decrementing the numbers instead
+  let incrementer = (a:0 > 0 ? '' : '')
+
+  if start_row == end_row
+    " just increment/decrement the value if only one line is selected
+    exe "normal! ".a:step.incrementer
+  else
+    " move to the next line, as we are not interested in incrementing the very
+    " first one
+    exe "normal! j"
+    " each next line is increased by this value, from the previous one
+    let i = a:step
+    while 1
+      " increment the current line by <i>
+      exe "normal! ".i.incrementer
+      " finish once the last row is incremented
+      if line('.') == end_row
+        break
+      endif
+      " move to the next line
+      call setpos('.', [0, line('.')+1, start_column, 0])
+      let i += a:step
+    endwhile
+  endif
+endfunction
+
+vnoremap <silent> <Plug>VisualIncrement :<C-U>call <SID>doincrement(v:count1)<CR>
+vnoremap <silent> <Plug>VisualDecrement :<C-U>call <SID>doincrement(v:count1, 1)<CR>
+
+if !hasmapto("<Plug>VisualIncrement")
+  vmap <C-A>  <Plug>VisualIncrement
+endif
+if !hasmapto("<Plug>VisualDecrement")
+  vmap <C-X>  <Plug>VisualDecrement
+endif
+
+let &cpo = s:cpo_save
+