Character-wise regions? #22

Closed
mattboehm opened this Issue Dec 9, 2013 · 6 comments

Comments

Projects
None yet
2 participants

I'm interested in using NrrwRgn to edit python docstrings that are RestructuredText. An example would be:

def format(...):
    """Return timestamp string with place holders replaced with values.

    Keyword arguments:
    timestamp     -- the format string (default '')
    priority      -- priority number (default '')
    priority_name -- priority name (default '')
    message       -- message to display (default '')
    """

I would not want the triple-quotes to be included in the region as this could mess up the syntax highlighting for the region.

I imagine switching everything to not be linewise might be too complicated an edit for a limited use case, but wanted to get your thoughts. I suppose I might be able to use the hooks to delete the quotes on enter and add them back in on write instead...

Owner

chrisbra commented Dec 10, 2013

On Mon, December 9, 2013 23:52, Matthew Boehm wrote:

I'm interested in using NrrwRgn to edit python docstrings that are
RestructuredText. An example would be:

def format(...):
    """Return timestamp string with place holders replaced with values.

    Keyword arguments:
    timestamp     -- the format string (default '')
    priority      -- priority number (default '')
    priority_name -- priority name (default '')
    message       -- message to display (default '')
    """

I would not want the triple-quotes to be included in the region as this
could mess up the syntax highlighting for the region.

I imagine switching everything to not be linewise might be too complicated
an edit for a limited use case, but wanted to get your thoughts. I suppose
I might be able to use the hooks to delete the quotes on enter and add
them back in on write instead...

You could of course try to work with hooks (see :h NR-hooks), but wouldn't
it be simpler, to use a characterwise region and use the nr or
Nr mappings (see :h NR-HowTo)?

Best,
Christian

That does not seem to work as expected. I've recorded a small screencast that shows what happens when I highlight text and hit <leader>nr with a freshly pulled copy of NrrwRgn. This is followed by a short example of what I expect to do (but please ignore the fact that I accidentally included a closing quote in my selection.) http://asciinema.org/a/6706

Owner

chrisbra commented Dec 10, 2013

Hi Matthew!

On Di, 10 Dez 2013, Matthew Boehm wrote:

That does not seem to work as expected. I've recorded a small screencast that shows what happens when I highlight text and hit <leader>nr with a freshly pulled copy of NrrwRgn. This is followed by a short example of what I expect to do (but please ignore the fact that I accidentally included a closing quote in my selection.) http://asciinema.org/a/6706

Looks like you used line-wise visual selection. Did you try to use a
character wise selection (e.g. using ?

regards,

Christian

Input - Output - Kaputt

I was using character-wise selection (v) but block-wise selection (ctrl-v) gives me the same result; perhaps there is a bug? All 3 selection modes only give me the full first line when I hit nr despite multiple lines being selected.

Owner

chrisbra commented Dec 10, 2013

On Tue, December 10, 2013 15:39, Matthew Boehm wrote:

That does not seem to work as expected. I've recorded a small screencast
that shows what happens when I highlight text and hit <leader>nr with a
freshly pulled copy of NrrwRgn. This is followed by a short example of
what I expect to do (but please ignore the fact that I accidentally
included a closing quote in my selection.) http://asciinema.org/a/6706

Indeed, it looks like you discovered a bug in the last commit.
Please try the previous commit, that should work.

I must have been using the previous version accidently.

chrisbra closed this in 02ba492 Dec 10, 2013

Awesome, works as expected now =). Thanks for the really quick response.

@vim-scripts vim-scripts added a commit to vim-scripts/NrrwRgn that referenced this issue Mar 28, 2014

@chrisbra @vim-scripts chrisbra + vim-scripts Version 32
- hooks could corrupt the narrowed buffer, if it wasn't closed (reported by  jszakemeister chrisbra/NrrwRgn#19, thanks!)- Don't parse /doc/options.txt for finding out buffer-local options  (reported by AguirreIF chrisbra/NrrwRgn#21,  thanks!), instead include a fix set of option names to set when opening the  narrowed buffer.- Switching buffers in the original narrowed buffer, may confuse NrrwRgn.- Code cleanup (no more separate functions for visual and normal mode)- fix issue 22 (characterwise narrowing was brocken in last commit, reported  by Matthew Boehm in chrisbra/NrrwRgn#22, thanks!)- in characterwise visual selection, trailing \n is not stripped when writing  (reported by Matthew Boehm in https://github.com/chrisbra/NrrwRgn/23,  thanks!)- highlighting was wrong for characterwise visual selections- update original window for multi narrowed regions (  https://github.com/chrisbra/NrrwRgn/24, reported by Dane Summers, thanks!),  use the g:nrrw_rgn_update_orig_win variable to enable- error when narrowed window was moved to new tab and trying to quit  (https://github.com/chrisbra/NrrwRgn/2, reported by Mario Ricalde, thanks!)- better default names for the narrowed window  (https://github.com/chrisbra/Nrrwrgn/28, reported by Mario Ricalde, thanks!)- when setting g:nrrw_rgn_write_on_sync the original file will be saved,  whenever the narrowed window is written back  (https://github.com/chrisbra/26, reported by Mario Ricalde, thanks!)- Some more error handling when using |:WidenRegion|- Make sure highlighting is removed when using |:WidenRegion|(automatically uploaded)
5033995
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment