Skip to content

Commit

Permalink
Merge github.com:chrisbra/NrrwRgn
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbra committed Nov 3, 2011
2 parents 4b2c404 + b703b01 commit f64af89
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions doc/NarrowRegion.txt
Expand Up @@ -29,22 +29,22 @@ This plugin is based on a discussion in comp.editors (see the thread at
http://groups.google.com/group/comp.editors/browse_frm/thread/0f562d97f80dde13)

Narrowing means focussing on a region and making the rest inaccessible. You
simply select the region, call :NarrowRegion and the selected part will open
simply select the region, call |:NarrowRegion| and the selected part will open
in a new scratch buffer. The rest of the file will be protected, so you won't
accidentally modify that buffer. In the new buffer, you can do a global
replace, search or anything else to modify that part. When you are finished,
simply write that buffer (e.g. by |:w|) and your modifications will be put in
the original buffer making it accessible again.

NrrwRgn allows you to either select a line based selection using an Ex-command
or you can simply use any visual selected region and press your prefered key
or you can simply use any visual selected region and press your preferred key
combination to open that selection in a new buffer.

This plugin defines the following commands:

*:NarrowRegion* *:NR*
:[range]NR
:[range]NarrowRegion When [range] is omited, select only the current
:[range]NarrowRegion When [range] is omitted, select only the current
line, else use the lines in the range given and
open it in a new Scratch Window.
Whenever you are finished modifying that region
Expand Down Expand Up @@ -140,7 +140,7 @@ file. You would do it like this: >
:NRMulti
<
Now a Narrowed Window will open, that contains only the configuration lines.
Each block of independent region will be seperated by a string like
Each block of independent region will be separated by a string like

# Start NarrowRegion1
.....
Expand All @@ -159,7 +159,7 @@ When you are finished, simply write your changes back.
-------------------------

NarrowRegion can be customized by setting some global variables. If you'd
like to open the narrowed windo as a vertical split buffer, simply set the
like to open the narrowed window as a vertical split buffer, simply set the
variable g:nrrw_rgn_vert to 1 in your |.vimrc| >
let g:nrrw_rgn_vert = 1
Expand All @@ -182,15 +182,15 @@ result, you could put that in your |.vimrc| >
let g:nrrw_rgn_hl = 'Search'
<
If you want to turn off the highlighting (because this can be disturbing, you
If you want to turn off the highlighting (because this can be distracting), you
can set the global variable g:nrrw_rgn_nohl to 1 in your |.vimrc| >
let g:nrrw_rgn_nohl = 1
<
------------------------------------------------------------------------------

If you'd like to change the key combination, that starts the Narrowed Window
for you selected range, you could put this in your |.vimrc| >
If you'd like to change the key combination that starts the Narrowed Window
for your selected range, you could put this in your |.vimrc| >
xmap <F3> <Plug>NrrwrgnDo
<
Expand All @@ -200,18 +200,19 @@ mode, unless you want it to Narrow your last visually selected range.

------------------------------------------------------------------------------

If you like to specify the options, you want to have applied into the narrowed
window, you can set the g:nrrw_custom_options setting, in your |.vimrc| e.g. >
If you'd like to specify the options that you want to have set for the
narrowed window, you can set the g:nrrw_custom_options setting, in your
|.vimrc| e.g. >
let g:nrrw_custom_options={}
let g:nrrw_custom_options['filetype'] = 'python'
>
This will only apply those options to the narrowed buffer. You need to take care,
that all options you need will apply.
This will only apply those options to the narrowed buffer. You need to take
care that all options you need will apply.

------------------------------------------------------------------------------

If you don't like, that your narrowed window opens above to the current window,
If you don't like that your narrowed window opens above the current window,
define the g:nrrw_topbot_leftright variable to your taste, e.g. >
let g:nrrw_topbot_leftright = 'botright'
Expand All @@ -223,18 +224,18 @@ specified, the narrowed window will appear above/left of the original window.

If you want to use several independent narrowed regions of the same buffer
that you want to write at the same time, protecting the original buffer is not
really useful. Therfore, set the g:nrrw_rgn_protect variable, e.g. in your
really useful. Therefore, set the g:nrrw_rgn_protect variable, e.g. in your
|.vimrc| >
let g:nrrw_rgn_protect = 'n'
<
This can be useful, if you diff different regions of the same file, and want
to be able to put back the changes at different positions. Note, you should
make sure, not to accidently change those part, that will later be influenced
This can be useful if you diff different regions of the same file, and want
to be able to put back the changes at different positions. Please note that
you should take care not to change any part that will later be influenced
when writing the narrowed region back.

Note: Don't use overlapping regions! Your changes will probably not be put
back correctly and there is no guard against losing data accidently. NrrwRgn
back correctly and there is no guard against losing data accidentally. NrrwRgn
tries hard to adjust the highlighting and regions as you write your changes
back into the original buffer, but it can't guarantee that this will work and
might fail silently. Therefore, this feature is experimental!
Expand All @@ -244,7 +245,7 @@ might fail silently. Therefore, this feature is experimental!

NarrowRegion can execute certain commands, when creating the narrowed window
and when closing the narrowed window. For this, you can set 2 buffer-local
variables, that specify what commands to execute, which will hook into the
variables that specify what commands to execute, which will hook into the
execution of the Narrow Region plugin.

For example, suppose you have a file, containing columns separated data (CSV
Expand All @@ -253,15 +254,15 @@ format) which you want to modify and you also have the CSV filetype plugin
to modify the CSV data which should be visually arranged like a table in the
narrowed window.

Therefore you want that in the new narrowed window the command :ArrangeColumn
is executed after entering it, and when writing the changes back, you want
that the command :UnArrangeColumn will executed just before putting the
changes back. So you set those two variables, in your original buffer: >
Therefore you want the command |:ArrangeColumn| to be executed in the new
narrowed window upon entering it, and when writing the changes back, you want
the command |:UnArrangeColumn| to be executed just before putting the
changes back. So you set those two variables in your original buffer: >
let b:nrrw_aucmd_create = "set ft=csv|%ArrangeCol"
let b:nrrw_aucmd_close = "%UnArrangeColumn"
<
This will execute in the narrowed window the commands: >
This will execute the commands in the narrowed window: >
:set ft=csv
:%ArrangeCol
Expand Down Expand Up @@ -337,7 +338,7 @@ third line of this document.

0.17: November 23, 2010 {{{1
- cache the options, that will be set (instead of parsing
$VIMRUNTIME/doc/options.txt everytime) in the Narrowed Window
$VIMRUNTIME/doc/options.txt every time) in the Narrowed Window
- getting the options didn't work, when using an autocommand like this:
autocmd BufEnter * cd %:p:h
(reported by Xu Hong, Thanks!)
Expand Down Expand Up @@ -369,7 +370,7 @@ third line of this document.

0.10: May 20, 2010 {{{1

- Restore Cursorposition using winrestview() and winsaveview()
- Restore cursor position using winrestview() and winsaveview()
- fix a bug, that prevented the use of visual narrowing
- Make sure when closing the narrowed buffer, the content will be written to
the right original region
Expand All @@ -390,7 +391,7 @@ third line of this document.

0.8: May 18, 2010 {{{1

- the g:nrrw_rgn_sepwin variable can be used to force seperate Narrowed
- the g:nrrw_rgn_sepwin variable can be used to force separate Narrowed
Windows, so you could easily diff those windows.
- make the separating of several windows a little bit safer (look at the
bufnr(), so it should work without problems for several buffers)
Expand Down

0 comments on commit f64af89

Please sign in to comment.