├── autoload
└── line.vim
├── README.md
├── plugin
└── line.vim
├── LICENSE.md
└── doc
└── line.txt
/autoload/line.vim:
--------------------------------------------------------------------------------
1 | function! line#inner()
2 | norm! m`
3 | keepj norm! ^vg_
4 | endfunction
5 |
6 | " Special handling for the 'delete' operator:
7 | " it deletes the whole line but only the "inner" line gets into the register
8 | function! line#inner_delete(reg)
9 | norm! m`
10 | exec 'keepj norm! ^vg_"'.a:reg.'d'
11 | norm! "_dd
12 | endfunction
13 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # line.vim
2 |
3 | Vim "inner line" text object works on the text inside the line.
4 | Leading and trailing whitespace is ignored.
5 |
6 | ### Text object
7 |
8 | `_` (underscore) - "inner line"
9 |
10 | ### Examples
11 |
12 | - `v_` visually selects all the text in a line, except the
13 | leading and trailing whitespace.
14 |
15 | - `y_` yank "inner line".
16 |
17 | - `d_` delete the whole line, but only "inner line" gets into the register.
18 |
19 | ### Why?
20 |
21 | It's shorter to type than `^vg_` + operator.
22 |
23 | ### Installation
24 |
25 | * Vundle
26 | `Plugin 'bruno-/vim-line'`
27 |
28 | * Pathogen
29 | `git clone git://github.com/bruno-/vim-line.git ~/.vim/bundle/vim-line`
30 |
31 | ### License
32 |
33 | [MIT](LICENSE.md)
34 |
--------------------------------------------------------------------------------
/plugin/line.vim:
--------------------------------------------------------------------------------
1 | " ============================================================================
2 | " File: line.vim
3 | " Author: Bruno Sutic
4 | " WebPage: https://github.com/bruno-/vim-line
5 | " ============================================================================
6 |
7 | if exists('g:loaded_line') && g:loaded_line
8 | finish
9 | endif
10 | let g:loaded_line = 1
11 |
12 | let s:save_cpo = &cpo
13 | set cpo&vim
14 |
15 | onoremap (inner_line) :call line#inner()
16 | nnoremap (inner_line_delete) :call line#inner_delete(v:register)
17 | xnoremap (inner_line) :call line#inner()
18 |
19 | if get(g:, 'line_default_mappings', 1)
20 | omap _ (inner_line)
21 | nmap d_ (inner_line_delete)
22 | xmap _ (inner_line)
23 | endif
24 |
25 | let &cpo = s:save_cpo
26 | unlet s:save_cpo
27 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (C) Bruno Sutic
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the "Software"),
5 | to deal in the Software without restriction, including without limitation
6 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 | and/or sell copies of the Software, and to permit persons to whom the
8 | Software is furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included
11 | in all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
19 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/doc/line.txt:
--------------------------------------------------------------------------------
1 | *line.txt* vim "inner line" text object.
2 |
3 | Author: Bruno Sutic
4 |
5 | INTRODUCTION *line*
6 |
7 | Vim "inner line" text object works on the text inside the line. Leading and
8 | trailing whitespace is ignored.
9 |
10 | "Around line" mappings are unnecessary because vim has those built in.
11 | Check |cc|, |yy|, |dd|
12 |
13 |
14 | OPERATOR MAPS *line-maps*
15 |
16 | *line-_* *line-*
17 | _ Operator map that selects text inside the line,
18 | ignoring the leading and trailing whitespace.
19 | Equivalent to '^vg_' + |operator|.
20 | 'd_' deletes the whole line, but only "inner line"
21 | gets into the register.
22 |
23 | *g:line_default_mappings*
24 | To disable default map, add the following to your vimrc:
25 | >
26 | let g:line_default_mappings = 0
27 | <
28 | EXAMPLES *line-examples*
29 |
30 | v_ Visually selects all the text in a line, except the
31 | leading and trailing whitespace.
32 |
33 | y_ Yank "inner line".
34 |
35 | CONTRIBUTING *line-contributing*
36 |
37 | Contributing is welcome. Github repo:
38 |
39 | https://github.com/bruno-/vim-line
40 |
41 | CHANGELOG *line-changelog*
42 |
43 | v2.2.0: November 24, 2014 * autoload functions
44 | v2.1.0: November 16, 2014 * fix a bug with 'd_'
45 | v2.0.0: November 09, 2014 * delete operator handled specially
46 | v1.0.1: October 31, 2014 * Remember position
47 | v1.0.0: October 31, 2014 * v1.0.0
48 | v0.0.1: October 31, 2014 * Initial working version
49 |
50 | LICENSE *line-license*
51 |
52 | Copyright (c) Bruno Sutic. Distributed under the MIT license.
53 |
54 | vim:tw=78:ts=8:ft=help:norl:
55 |
--------------------------------------------------------------------------------