Skip to content

Commit 8c6cd89

Browse files
committed
Extract selection without opening the extract buffer was added
1 parent d0739dc commit 8c6cd89

3 files changed

Lines changed: 37 additions & 16 deletions

File tree

autoload/extract.vim

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Description: Extract selection to a new buffer
33
" Author: Alexander Skachko <alexander.skachko@gmail.com>
44
" Homepage: https://github.com/lucerion/vim-extract
5-
" Version: 0.3
5+
" Version: 0.4
66
" Licence: BSD-3-Clause
77
" ==============================================================
88

@@ -27,6 +27,9 @@ func! s:extract(start_line, end_line, count)
2727
if a:count
2828
call s:clear_buffer()
2929
call s:insert_selection(l:selection)
30+
if g:extract_hidden
31+
call s:close_buffer()
32+
endif
3033
endif
3134
endfunc
3235

@@ -35,6 +38,10 @@ func! s:open_buffer()
3538
call s:set_buffer_defaults()
3639
endfunc
3740

41+
func! s:close_buffer()
42+
silent exec 'close'
43+
endfunc
44+
3845
func! s:buffer_options()
3946
let l:default_buffer_options = {
4047
\ 'name': substitute(g:extract_name, '{filename}', expand('%:t'), 'g'),

doc/vim-extract.txt

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Author: Alexander Skachko <alexander.skachko@gmail.com>
44
Homepage: https://github.com/lucerion/vim-extract
5-
Version: 0.3
5+
Version: 0.4
66
Licence: BSD-3-Clause (see LICENSE)
77

88
===============================================================================
@@ -52,37 +52,47 @@ Manual
5252
COMMANDS *vim-extract-commands*
5353

5454
*:Extr*
55-
:[range]Extr {name} {position} or :[range]Extr {position} {name}
55+
:[range]Extr {buffer-name} {position} or :[range]Extr {position} {buffer-name}
5656

57-
In Visual mode - extract selection to a buffer, in Normal mode - open
58-
the extract buffer. Buffer will be opened with {name} at {position}.
59-
'name' and 'position' arguments are optional.
60-
Without 'position' argument buffer will be opened with last or Default
61-
position
62-
Possible {position} values: -top, -bottom, -left, -right, -tab
63-
Default {position} value: -top
57+
In Visual mode - extract selection to a new buffer, in Normal mode - open
58+
the extract buffer.
59+
Without 'position' argument the extract buffer will be opened with the last
60+
or default position.
61+
62+
Positions: -top, -bottom, -left, -right, -tab
63+
Default position: -top
6464

6565
===============================================================================
6666
OPTIONS *vim-extract-options*
6767

6868
*g:extract_name*
6969

70-
Pattern for the extract buffer name. {filename} will be replaced with current
71-
file name. This buffer name will be used if :Extr command was called without
72-
'name' argument.
70+
Pattern for the extract buffer name. {filename} will be replaced with the
71+
current file name. This option will be used if :Extr command was called
72+
without 'name' argument.
7373

7474
Default: '_{filename}'
7575

7676
*g:extract_append*
7777

78-
Append selected text to the end of the extract buffer (1) or clear the extract
79-
buffer and insert selection (0)
78+
Append selection to the end of the extract buffer (1) or clear the extract
79+
buffer before insertation (0).
8080

8181
Default: 1
8282

83+
*g:extract_hidden*
84+
85+
Extract selection without opening the extract buffer.
86+
87+
Default: 0
88+
8389
===============================================================================
8490
CHANGELOG *vim-extract-changelog*
8591

92+
0.4.0 (2016-09-19)~
93+
Changes
94+
* extract selection without opening the extract buffer option was added
95+
8696
0.3.0 (2016-03-27)~
8797
vim-buffr plugin version 0.3 required
8898

plugin/extract.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Description: Extract selection to a new buffer
33
" Author: Alexander Skachko <alexander.skachko@gmail.com>
44
" Homepage: https://github.com/lucerion/vim-extract
5-
" Version: 0.3
5+
" Version: 0.4
66
" Licence: BSD-3-Clause
77
" ==============================================================
88

@@ -18,6 +18,10 @@ if !exists('g:extract_append')
1818
let g:extract_append = 1
1919
endif
2020

21+
if !exists('g:extract_hidden')
22+
let g:extract_hidden = 0
23+
endif
24+
2125
let s:allowed_args = ['-top', '-bottom', '-left', '-right', '-tab']
2226

2327
func! s:autocompletion(A, L, C)

0 commit comments

Comments
 (0)