Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include basic help file #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions doc/increment.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
*increment.vim* Yet another script for incrementing numbers.

(text copied from http://www.vim.org/scripts/script.php?script_id=156 in 13/06/2012)
script karma Rating 272/97, Downloaded by 4092
created by Srinath Avadhanula

description
This script provides a way to quickly create incremented lists (either
increasing or decreasing) using the visual block mode.

Synopsis:
=========
1. Suppose you have a column of the following form:
array(1) = 3;
array(1) = 3;
array(1) = 3;
array(1) = 3;
array(1) = 3;
2. Choose the column of '1's using Ctrl-V and then run the command Inc (you
should see "'<,'>Inc" on the command line at this point)(if you do not
have any other user commands starting with 'I', just I will suffice).
This will tranform the text as:
array(1) = 3; array(1) = 3;
array(1) = 3; array(2) = 3;
array(1) = 3; --> array(3) = 3;
array(1) = 3; array(4) = 3;
array(1) = 3; array(5) = 3;
3. You can then choose the column of '3's (again using Ctrl-V) and run the
command "Inc 3" to generate another incremented list. This will
generate:
array(1) = 3; array(1) = 3;
array(2) = 3; array(2) = 6;
array(3) = 3; --> array(3) = 9;
array(4) = 3; array(4) = 12;
array(5) = 3; array(5) = 15;

Note: increment.vim automatically pads the numbers in the the column
with spaces in order to get them right aligned. This is useful in most
cases, but for cases when this might be bad, use IncN which doesnt do
any alignment.

Commands provided:
==================
1. Inc : generates a column of increasing numbers with RIGHT alignment.
2. IncN: generates a column of increasing numbers with NO alignment.
3. IncL: generates a column of increasing numbers with LEFT alignment

Tip:
A mapping which goes well with this command is the following:

vnoremap <c-a> :Inc<CR>

With this mapping, select a column of numbers and press Ctrl-A, which will
get them in increasing order. I use <c-a> because its similar to the <c-a>
command in normal mode which increments the number under the cursor.

Acknowledgements:
===============
There are other scripts which have been made to do almost the same thing.
Charles E Campbell's vimtip #150 uses a similar visual block strategy
Stanislav Sitar's vimscript #145 uses a searc/replace strategy


install details
drop the file in the vim plugins directory.

vim: tw=78:ts=8:ft=help:fdm=marker
7 changes: 7 additions & 0 deletions plugin/increment.vim
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
" Last Modification: Dec 17 2001 00:59:09


if exists('g:loaded_increment') || &cp || version < 700
finish
endif
let g:loaded_increment= 1



"===========================================================================
com! -ra -nargs=? Inc :call IncrementColumn(1,<args>)
com! -ra -nargs=? IncR :call IncrementColumn(2,<args>)
Expand Down