Rostyslaw Lewyckyj | 1 Mar 2011 02:49

Editing contents of a register?

Suppose that I have a collection of editing commands such as
%g/pattern_a/
%g/pattern_b/
%g/pattern_c/
........................
that find and list all the lines of a file that satisfy some patterns.
After I visually inspect a given list of lines,  I may want to delete them.

I have thought to do this as follows:
-- yank a list command into a register       "ayy
-- execute the command              : <at> a"
-- inspect the lines as they are listed

Then if I'd now like to delete this set of lines, I'd like to append a   d
to the contents of register a changing it from a list to a delete command,
and execute the command.

So how do I _easily_ modify, edit, the contents of a register?

I'd like something simpler than loading a list command into the clipboard
via highlighting and ^C followed by :^V and if choosing to delete
then :^Vd   ???
-- 
Rostyk

--

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

(Continue reading)

Ben Schmidt | 1 Mar 2011 02:51
Picon
Gravatar

Re: using the help system in split screen mode

>> You may want to change "&ft" (shortcut to "&filetype") to "&bt"
>> (shortcut to "&buftype"), but I would use&ft because vim behavior
>> when you have more then one buffer with 'buftype' set to `help' is
>> undefined

How do you figure that? You can easily get multiple buffers with
buftype=help perfectly naturally by splitting help windows and moving to
new help topics, using commands like ctrl-w ctrl-], and so on, and Vim
behaves perfectly normally and as expected.

>> (that is why I would have written `setl bt= | vert help
>> subject' instead of suggested `vnew | set bt=help | help subject').

Well, my set should definitely have been setl, but apart from that, I
think it's still arguably a better approach.

> The suggested pipe ‘setl bt= | help’ does indeed override Vim's miserly
> behavior relative to help windows..
>
> Why?

Because Vim identifies help windows by the buftype, so if you clear it,
Vim no longer thinks it is a help window, so doesn't reuse it.

I would advise against this, as it has other side effects, e.g. using
:help in the existing window will not reuse it as desired, but open a
new window. A few other help-window-specific behaviours will also not
work on the old help window if you do this.

> Another quick question.. in Vimscript, what is the natural idiom to code:
(Continue reading)

Ben Schmidt | 1 Mar 2011 03:00
Picon
Gravatar

Re: Editing contents of a register?

On 1/03/11 12:49 PM, Rostyslaw Lewyckyj wrote:
> Suppose that I have a collection of editing commands such as
> %g/pattern_a/
> %g/pattern_b/
> %g/pattern_c/
> ........................
> that find and list all the lines of a file that satisfy some patterns.
> After I visually inspect a given list of lines, I may want to delete them.
>
> I have thought to do this as follows:
> -- yank a list command into a register "ayy
> -- execute the command : <at> a"
> -- inspect the lines as they are listed
>
> Then if I'd now like to delete this set of lines, I'd like to append a d
> to the contents of register a changing it from a list to a delete command,
> and execute the command.
>
> So how do I _easily_ modify, edit, the contents of a register?
>
> I'd like something simpler than loading a list command into the clipboard
> via highlighting and ^C followed by :^V and if choosing to delete
> then :^Vd ???

You can enter any register onto the commandline by using ^R, so just do
this if you want (after pressing a, the contents of the register will
appear on the commandline)

:^Rad

(Continue reading)

Tim Chase | 1 Mar 2011 04:27

Re: Editing contents of a register?

On 02/28/2011 07:49 PM, Rostyslaw Lewyckyj wrote:
> Suppose that I have a collection of editing commands such as
> %g/pattern_a/
> %g/pattern_b/
> %g/pattern_c/
> ........................
> that find and list all the lines of a file that satisfy some patterns.
> After I visually inspect a given list of lines,  I may want to delete them.
>
> I have thought to do this as follows:
> -- yank a list command into a register       "ayy
> -- execute the command              : <at> a"
> -- inspect the lines as they are listed
>
> Then if I'd now like to delete this set of lines, I'd like to append a   d
> to the contents of register a changing it from a list to a delete command,
> and execute the command.
>
> So how do I _easily_ modify, edit, the contents of a register?
>
> I'd like something simpler than loading a list command into the clipboard
> via highlighting and ^C followed by :^V and if choosing to delete
> then :^Vd   ???

I've done something like this in the past where I've modified my 
buffer such as you have with

   :%s/.*/:&d

which leaves the buffer looking like
(Continue reading)

Benjamin R. Haskell | 1 Mar 2011 04:36
Favicon
Gravatar

Re: using the help system in split screen mode

On Mon, 28 Feb 2011, Chris Jones wrote:

> Another quick question.. in Vimscript, what is the natural idiom to 
> code:
>
> if count == 0; do proc_0; fi
> if count == 1; do proc_1; fi
> if count >  1; do proc_n; fi

In what language is that a natural idiom?  Is it...

... a for loop?  VimL has :for loops if you're just trying to call a 
function for 0 through 'count':

" +1 makes it [0,count] inclusive
for i in range(count+1)
 	call Proc(i)
endfor

See:
:help range()
:help :for

... something recursive?

fun! Factorial(count)
 	if a:count < 2
 		return 1
 	endif
 	return a:count * Factorial(a:count - 1)
(Continue reading)

ZyX | 1 Mar 2011 05:53
Picon

Re: using the help system in split screen mode

Reply to message «Re: using the help system in split screen mode», 
sent 02:23:45 01 March 2011, Tuesday
by Chris Jones:

> The suggested pipe ‘setl bt= | help’ does indeed override Vim's miserly
> behavior relative to help windows..
> 
> Why?
Because vim uses 'buftype' to check whether some buffer is a help buffer. If you 
write your own plugin and edit a help file, then you won't have 'buftype' set to 
`help'.

> Another quick question.. in Vimscript, what is the natural idiom to code:
> 
> if count == 0; do proc_0; fi
> if count == 1; do proc_1; fi
> if count >  1; do proc_n; fi
What language is this? On zsh I would have written this as
    if   (( count==0 )) ; then proc_0
    elif (( count==1 )) ; then proc_1
    elif (( count>1  )) ; then proc_n
    fi
. In vim:
    if     count==0 | proc_0
    elseif count==1 | proc_1
    elseif count>1  | proc_n
    endif
(Note that `count' is alias to read-only variable v:count that is keeped for 
backwards compatibility, so you may not use it in your script with other 
meaning.)
(Continue reading)

ZyX | 1 Mar 2011 06:01
Picon

Re: using the help system in split screen mode

Reply to message «Re: using the help system in split screen mode», 
sent 04:51:03 01 March 2011, Tuesday
by Ben Schmidt:

> How do you figure that? You can easily get multiple buffers with
> buftype=help perfectly naturally by splitting help windows and moving to
> new help topics, using commands like ctrl-w ctrl-], and so on, and Vim
> behaves perfectly normally and as expected.
Just point me where help describes which of multiple buffers with 'bt' set to 
`help' will be used to open new help topic? Also note that ``:h 'bt''' says that 
you are not supposed to set 'buftype' to `help' manually.

> Well, my set should definitely have been setl, but apart from that, I
> think it's still arguably a better approach.
I would have agreed with you if it was described in a documentation: your 
solution should delete buffers on window close, while my won't.

Original message:
> >> You may want to change "&ft" (shortcut to "&filetype") to "&bt"
> >> (shortcut to "&buftype"), but I would use&ft because vim behavior
> >> when you have more then one buffer with 'buftype' set to `help' is
> >> undefined
> 
> How do you figure that? You can easily get multiple buffers with
> buftype=help perfectly naturally by splitting help windows and moving to
> new help topics, using commands like ctrl-w ctrl-], and so on, and Vim
> behaves perfectly normally and as expected.
> 
> >> (that is why I would have written `setl bt= | vert help
> >> subject' instead of suggested `vnew | set bt=help | help subject').
(Continue reading)

doherty pete | 1 Mar 2011 05:20
Picon

vim can use font of comic sans?

i want to use font of comic sans,it can only use at gvim?

--
pete_doherty

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Ben Schmidt | 1 Mar 2011 08:29
Picon
Gravatar

Re: using the help system in split screen mode

>> How do you figure that? You can easily get multiple buffers with
>> buftype=help perfectly naturally by splitting help windows and moving to
>> new help topics, using commands like ctrl-w ctrl-], and so on, and Vim
>> behaves perfectly normally and as expected.
> Just point me where help describes which of multiple buffers with 'bt' set to
> `help' will be used to open new help topic? Also note that ``:h 'bt''' says that
> you are not supposed to set 'buftype' to `help' manually.

LOL, OK, fair enough. It's not well-defined, but it isn't unpredictable
or undesirable either. So it's not a bad kind of undefined.

Setting 'bt' to help manually won't be a problem, particularly as the
buffer will shortly be unloaded (when the window is changed to show a
real help buffer). Of course, things could be a little icky in the case
that a help topic doesn't exist.

Neither approach is ideal.

Ben.

--

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Ben Schmidt | 1 Mar 2011 08:31
Picon
Gravatar

Re: vim can use font of comic sans?

> i want to use font of comic sans,it can only use at gvim?

You shouldn't really do this in gvim or vim, because Comic Sans is not a 
monospaced font. Some GUIs will allow you to do it in gvim, though.

Ben.

--

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Gmane