Saturday, April 30, 2011

RE: determine if a certain line occurs in a file

cyboman wrote:
> i'm trying to write a small vim function which will modify a
> copyright year each time i'm opening a file.

You might want to look at the ideas here:
http://vim.wikia.com/wiki/Automatically_Update_Copyright_Notice_in_Files

John

--
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

Re: set tags # look for TAGS in current folder and up?

On Apr 30, 1:45 pm, Ben Schmidt <mail_ben_schm...@yahoo.com.au> wrote:

> But, it is probably better to try
>
>     :set tags=./TAGS;
>

Thank you, this works for me.

--
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

Re: How to get undo functionality after :bnext

On 04/30/2011 05:33 PM, reckoner wrote:
> On 4/29/2011 1:51 PM, Tim Chase wrote:
>> On 04/29/2011 03:47 PM, Reckoner wrote:
>>> When editing multiple buffers, I do :bnext to get to the
>>> next buffer. Unfortunately, when I return to that buffer
>>> or one of the previously edited buffers, I can no longer
>>> "undo" the changes in the corresponding buffer.
>>>
>>> Is there a way to set it up so that even if I do :bnext
>>> that I can still undo changes when I return to the same
>>> buffer?
>>
>> :set hidden
>>
>> :help 'hidden'
>
> Thanks for your response, but I'm going to need a bigger hint
> than that. That section of the manual is not very well
> written. I'm not having much luck understanding it.

[reordering and trimming as advised in the footer of each message
that comes from the list...top-posting is discouraged]

If you add the line

set hidden

to your local vimrc, it will turn this on globally. This allows
you to leave a buffer (such as with ":bnext", ":enew", ":n", etc)
while maintaining your undo/marks, etc. When you return to that
buffer, you retain all those marks and undo-ability. It also
doesn't force you to write the file or abandon the changes (which
it would do otherwise with the default "set nohidden").

-tim


--
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

Re: How to get undo functionality after :bnext

Thanks for your response, but I'm going to need a bigger hint than that.
That section of the manual is not very well written. I'm not having much
luck understanding it.

Thanks!


On 4/29/2011 1:51 PM, Tim Chase wrote:
> On 04/29/2011 03:47 PM, Reckoner wrote:
>> When editing multiple buffers, I do :bnext to get to the next buffer.
>> Unfortunately, when I return to that buffer or one of the previously
>> edited buffers, I can no longer "undo" the changes in the
>> corresponding buffer.
>>
>> Is there a way to set it up so that even if I do :bnext that I can
>> still undo changes when I return to the same buffer?
>
> :set hidden
>
> :help 'hidden'
>
> -tim
>
>

--
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

Re: Ignore the folding

[CCing the list again.]

On 1/05/11 3:33 AM, JuanPabloAJ wrote:
> I started a plugin with this objetive,
> https://github.com/juanpabloaj/absolutFold
> welcome yours comments or issues.
>
> Regards
>
> --
> JuanPabloAJ
>
> On sábado 30 de abril de 2011 at 3:55, Ben Schmidt wrote:
>
>> On 30/04/11 4:12 PM, JuanPabloAJ wrote:
>>> I use syntax folding with C++. How do I ignore the folding in my
>>> while, if and for constructs?
>>
>> I don't think you can do exactly this easily. C code folding is simply
>> based on { } blocks, not statements (see :help ft-c-syntax). Making it
>> do something else would be very hard, too, I think.
>>
>> If you just want to fold one level, and no more (i.e. functions, but
>> never anything within functions), you could do
>>
>> :set foldnestmax=1
>>
>> Or using 2 might be better, if you work with lots of inline functions
>> defined in classes' header files.
>>
>> Alternatively, using marker folding or something like that is an option.
>>
>> Any of those ideas any good?
>>
>> 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

Re: set tags # look for TAGS in current folder and up?

> When browsing through source I want tag file TAGS to be searched for
> in the folder of the current file and then up the parent folders.
>
> On my first try it seems this is not working:
>
> set tags=./TAGS,../TAGS,../../TAGS,../../../TAGS,../../../../TAGS
>
> Any ideas?

My guess is that it's probably looking relative to the current
directory, not the current file, and you want the latter. You could use

:set tags=./TAGS,./../TAGS,./../../TAGS

The explicit ./ should make it relative to the file, not the current
directory.

But, it is probably better to try

:set tags=./TAGS;

This uses an upward search which apparently works for the 'tags' option
(:help file-searching).

It is important that 'd' is not in cpoptions. Check this with

:set cpo?

And use

:set cpo-=d

if you need to fix it.

See :help 'tags' for a little more info and cross-references.

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

Re: is there s 'toinitialupper' function?

On Apr 30, 9:36 am, Tim Chase <v...@tim.thechases.com> wrote:
> On 04/30/2011 10:39 AM, Bee wrote:
>
> > On Apr 29, 4:47 pm, "John Beckett"<johnb.beck...@gmail.com>  wrote:
> >> Tim Chase wrote:
> >>>    let s=substitute(s, '\w\+', '\u\1', 'g')
>
> >> The above is intended to change each word in s, making the first
> >> letter uppercase and not changing the rest.
>
> >> The search pattern needs brackets, or the \1 should be replaced.
> >> The following works:
>
> >>    let s=substitute(s, '\w\+', '\u&', 'g')
>
> > How would I pass the visual selection to a function with this
> > substitute?
>
> If you just want to do the replacement over the selected text,
> you can do the literal substitute:
>
>    :'<,'>s/\%V\w\+\%V/\u&/g
>
> or, if your selection starts/ends in the middle of a word and you
> don't want to effect them, you can riff on
>
>    :'<,'>s/\%V\<\w\+\>\%V/\u&/g
>
> adding/removing "\<" and "\>" as desired.  Any of these can
> pretty easily be mapped, e.g.
>
>    :vnoremap <f4> :s/\%V\w\+\%V/\u&/g<cr>
>
> If you want to take the selected text, pass it to this
> transforming function, and then assign it to a variable without
> altering the in-line text, you'll have to grab the selection
> either by yanking it to a register, or by using getline() or some
> such function (likely in a loop).  That gets a bit messy if you
> don't yank it to a known register.
>
> -tim
>
> PS: yeah, John caught my "just a little change after I copy &
> paste" flub where I previously had used \(...\) to capture things
> and \1 referred to them.  Sorry if it caused any confusion.

I already have the following which works great:
" Title Case A Line Or Selection
vnoremap <F6> :s/\%V\<\(\w\)\(\w*\)\>/\u\1\L\2/ge<cr>

But I would like to know how to do it in a "function" for the
educational value.

function! TitleCase()
let save = @r
normal! gv"rx
let @r = substitute(@r, '\(\w\)\(\w*\)', '\u\1\L\2', 'g')
normal! "rP`<
let @r = save
endfun

This also works, but seems too "messy".
Can it be simplified?

-Bill

--
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

set tags # look for TAGS in current folder and up?

When browsing through source I want tag file TAGS to be searched for
in the folder of the current file and then up the parent folders.

On my first try it seems this is not working:

set tags=./TAGS,../TAGS,../../TAGS,../../../TAGS,../../../../TAGS

Any ideas?

--
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

Re: is there s 'toinitialupper' function?

On 04/30/2011 10:39 AM, Bee wrote:
> On Apr 29, 4:47 pm, "John Beckett"<johnb.beck...@gmail.com> wrote:
>> Tim Chase wrote:
>>> let s=substitute(s, '\w\+', '\u\1', 'g')
>>
>> The above is intended to change each word in s, making the first
>> letter uppercase and not changing the rest.
>>
>> The search pattern needs brackets, or the \1 should be replaced.
>> The following works:
>>
>> let s=substitute(s, '\w\+', '\u&', 'g')
>
> How would I pass the visual selection to a function with this
> substitute?

If you just want to do the replacement over the selected text,
you can do the literal substitute:

:'<,'>s/\%V\w\+\%V/\u&/g

or, if your selection starts/ends in the middle of a word and you
don't want to effect them, you can riff on

:'<,'>s/\%V\<\w\+\>\%V/\u&/g

adding/removing "\<" and "\>" as desired. Any of these can
pretty easily be mapped, e.g.

:vnoremap <f4> :s/\%V\w\+\%V/\u&/g<cr>

If you want to take the selected text, pass it to this
transforming function, and then assign it to a variable without
altering the in-line text, you'll have to grab the selection
either by yanking it to a register, or by using getline() or some
such function (likely in a loop). That gets a bit messy if you
don't yank it to a known register.

-tim

PS: yeah, John caught my "just a little change after I copy &
paste" flub where I previously had used \(...\) to capture things
and \1 referred to them. Sorry if it caused any confusion.


--
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

Re: is there s 'toinitialupper' function?

On Apr 29, 4:47 pm, "John Beckett" <johnb.beck...@gmail.com> wrote:
> Tim Chase wrote:
> >   let s=substitute(s, '\w\+', '\u\1', 'g')
>
> The above is intended to change each word in s, making the first
> letter uppercase and not changing the rest.
>
> The search pattern needs brackets, or the \1 should be replaced.
> The following works:
>
>   let s=substitute(s, '\w\+', '\u&', 'g')

How would I pass the visual selection to a function with this
substitute?

-Bill

--
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

Re: determine if a certain line occurs in a file

Reply to message «determine if a certain line occurs in a file»,
sent 15:47:43 30 April 2011, Saturday
by cyboman:

You can either force vim to ignore an error message by using `silent!', or use
`search()':

let oldy='2010'
let newy=strftime('%Y')
let line=search('Copyright '.oldy.', Company E', 'n')
if line
call setline(line, substitute(getline(line), oldy, oldy.'-'.newy, ''))
endif
My version with setline/getline and 'n' argument to `search()' does not move the
cursor.

Original message:
> i'm trying to write a small vim function which will modify a copyright
> year each time i'm opening a file. here is what i came up with
>
> function UpdateCopyrightYear()
> let l:cmd = 's/\(\d\+\)/\1-'.strftime("%Y").'/'
> g/Copyright 2010, Company E/exec l:cmd
> endfunction
>
> the problem that i'm facing right now is if the pattern is not in the
> file, i get an error message, E486: Pattern not found Copyright 2010,
> Company E. is there a way to tell vim not to execute the command if
> pattern is not found, say something like:
>
> function UpdateCopyrightYear()
> let l:cmd = 's/\(\d\+\)/\1-'.strftime("%Y").'/'
> if g/Copyright 2010, Company E/
> g/Copyright 2010, Company E/exec l:cmd
> endif
> endfunction
>
> thanks, any help is appreciated.

Re: determine if a certain line occurs in a file

Hi cyboman!

On Sa, 30 Apr 2011, cyboman wrote:

> the problem that i'm facing right now is if the pattern is not in the
> file, i get an error message, E486: Pattern not found Copyright 2010,
> Company E. is there a way to tell vim not to execute the command if
> pattern is not found, say something like:
>
> function UpdateCopyrightYear()
> let l:cmd = 's/\(\d\+\)/\1-'.strftime("%Y").'/'
> if g/Copyright 2010, Company E/

if search('Copyright 2010, Company E', 'n')

> g/Copyright 2010, Company E/exec l:cmd
> endif
> endfunction

regards,
Christian

--
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

determine if a certain line occurs in a file

i'm trying to write a small vim function which will modify a copyright
year each time i'm opening a file. here is what i came up with

function UpdateCopyrightYear()
let l:cmd = 's/\(\d\+\)/\1-'.strftime("%Y").'/'
g/Copyright 2010, Company E/exec l:cmd
endfunction

the problem that i'm facing right now is if the pattern is not in the
file, i get an error message, E486: Pattern not found Copyright 2010,
Company E. is there a way to tell vim not to execute the command if
pattern is not found, say something like:

function UpdateCopyrightYear()
let l:cmd = 's/\(\d\+\)/\1-'.strftime("%Y").'/'
if g/Copyright 2010, Company E/
g/Copyright 2010, Company E/exec l:cmd
endif
endfunction

thanks, any help is appreciated.

--
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

Re: is there s 'toinitialupper' function?

On 30 Apr 2011, at 00:47, John Beckett wrote:

> Tim Chase wrote:
>> let s=substitute(s, '\w\+', '\u\1', 'g')
>
> The above is intended to change each word in s, making the first
> letter uppercase and not changing the rest.
>
> The search pattern needs brackets, or the \1 should be replaced.
> The following works:
>
> let s=substitute(s, '\w\+', '\u&', 'g')

Tim/John

Thanks for your suggestions. That's much simpler than I was going to do (cut the word to pieces with strpart, capitalise with toupper, then join them back together).

Regards, Andy

--
Andrew Long
andrew dot long at mac dot com

Re: Ignore the folding

On 30/04/11 4:12 PM, JuanPabloAJ wrote:
> I use syntax folding with C++. How do I ignore the folding in my
> while, if and for constructs?

I don't think you can do exactly this easily. C code folding is simply
based on { } blocks, not statements (see :help ft-c-syntax). Making it
do something else would be very hard, too, I think.

If you just want to fold one level, and no more (i.e. functions, but
never anything within functions), you could do

:set foldnestmax=1

Or using 2 might be better, if you work with lots of inline functions
defined in classes' header files.

Alternatively, using marker folding or something like that is an option.

Any of those ideas any good?

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

Re: Ignore the folding

This no is a automatic solution

-- 
JuanPabloAJ

On sábado 30 de abril de 2011 at 2:27, Tony Mechelynck wrote:

On 30/04/11 08:12, JuanPabloAJ wrote:
Hi,
I use syntax folding with C++. How do I ignore the folding in my while,
if and for constructs?

Best regards.
--
JuanPabloAJ

--
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

You mean, open all folds? zR


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
79. All of your most erotic dreams have a scrollbar at the right side.

--
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

Re: False indentations...

On 30/04/11 5:14 PM, meino.cramer@gmx.de wrote:
> Hi,
>
> when writing simple ASCII texts there are sometimes
> false indentations (as simulated starting with
> this line). I dont know, whethere a wrongly
> loaded script, a wrong option setting or what
> else is the reason for this. Is there any
> way (oops! This line was idented by the
> "false indentation"-effect and not intentionall
> by me) to check, what plugin touches a certain
> line or initiated a certain effect/modification
> of a line of text?

Looks like you have 'cindent' or 'smartindent' turned on and you don't
want it. It's indenting like for code: unclosed parentheses get an
indent, as do keywords such as else if there's not braces or a
semicolon.

:verbose set cindent? smartindent?
:set nocindent nosmartindent

(Of course, 'autoindent' is also relevant, but you perhaps want that.)

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

Re: False indentations...

Hi meino.cramer!

On Sa, 30 Apr 2011, meino.cramer@gmx.de wrote:

> when writing simple ASCII texts there are sometimes
> false indentations (as simulated starting with
> this line). I dont know, whethere a wrongly
> loaded script, a wrong option setting or what
> else is the reason for this. Is there any
> way (oops! This line was idented by the
> "false indentation"-effect and not intentionall
> by me) to check, what plugin touches a certain
> line or initiated a certain effect/modification
> of a line of text?

This looks like you have the 'n' in your formatoptions 'fo'
So check the output of:
:set fo? flp? ai?

See
:h fo-table
:h 'flp'

regards,
Christian
--

--
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

Re: User command with -nargs=1

On 30/04/11 2:42 PM, John Beckett wrote:
> I thought defining a user command with '-nargs=1' would mean
> that using more than one argument would give an error, however
> I can't see a difference between nargs=1 and nargs=*.

I think it just means that it sees the command as having one single
argument, and the spaces are considered part of it, rather than breaking
it into multiple arguments. This possibly only shows up if you use
<f-args>, as arguments are separated.

Try the following code:

command! -nargs=1 TestOne call Test(<f-args>)
command! -nargs=* TestMany call Test(<f-args>)
function! Test(...)
let n = 1
while n <= a:0
call append('$', 'arg '.n.': '.eval('a:'.n))
let n = n+1
endwhile
endfunction
TestOne a b c d
TestMany a b c d

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

False indentations...

Hi,

when writing simple ASCII texts there are sometimes
false indentations (as simulated starting with
this line). I dont know, whethere a wrongly
loaded script, a wrong option setting or what
else is the reason for this. Is there any
way (oops! This line was idented by the
"false indentation"-effect and not intentionall
by me) to check, what plugin touches a certain
line or initiated a certain effect/modification
of a line of text?

Best regards,
mcc

--
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

Re: How do define a default highlight for none-linked group?

> I don't do anything with it, and yet:
>
> :hi CursorIM
> E411: highlight group not found: CursorIM
>
> The same happens with "vim -N -u NONE" or with "vim -u
> /usr/local/share/vim/vim73/vimrc_example.vim" with or without --noplugin.

Interesting. When I tested, I just did :hi clear, which evidently
doesn't actually clear things fully as I thought it would. Perhaps this
is a bug.

The result, though, is yes, that your approach using "default" will
work, at least for CursorIM, though not for other standard highlight
groups which are defined with defaults.

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

Friday, April 29, 2011

Re: Ignore the folding

On 30/04/11 08:12, JuanPabloAJ wrote:
> Hi,
> I use syntax folding with C++. How do I ignore the folding in my while,
> if and for constructs?
>
> Best regards.
> --
> JuanPabloAJ
>
> --
> 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

You mean, open all folds? zR


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
79. All of your most erotic dreams have a scrollbar at the right side.

--
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

Re: User command with -nargs=1

On 30/04/11 06:42, John Beckett wrote:
> I thought defining a user command with '-nargs=1' would mean
> that using more than one argument would give an error, however
> I can't see a difference between nargs=1 and nargs=*.
>
> command! -nargs=1 Test call Test('<args>')
> function! Test(args)
> call append('$', 'args: "' . a:args . '"')
> endfunction
>
> After sourcing the above:
> :new
> :Test (E471 Argument required; good)
> :Test a (displays 'args: "a"'; good)
> :Test a b (displays 'args: "a b"'; bad?)
>
> I thought '-nargs=1' would give "E488: Trailing characters"
> if more than one argument, and isn't "a b" two args?
>
> Above tested with Vim 7.3.170 and 7.2.18 on Windows and Linux.
>
> Is this something to do with allowing spaces in file names?
>
> John
>

Further experiment shows the following difference: with -nargs=1, ":Test
a b" sees one argument, 'a b'; with -nargs=* it sees two, 'a','b'. Try
the following (untested):

command! -nargs=* Type echo List(<f-args>)
function! List(...)
return a:000
enfunction

and try
:Type a b
-- then the same after replacing -nargs=1 by -nargs=*


Best regards,
Tony.
--
"I cannot read the fiery letters," said Frito Bugger in a
quavering voice.
"No," said GoodGulf, "but I can. The letters are Elvish, of
course, of an ancient mode, but the language is that of Mordor, which
I will not utter here. They are lines of a verse long known in
Elven-lore:

"This Ring, no other, is made by the elves,
Who'd pawn their own mother to grab it themselves.
Ruler of creeper, mortal, and scallop,
This is a sleeper that packs quite a wallop.
The Power almighty rests in this Lone Ring.
The Power, alrighty, for doing your Own Thing.
If broken or busted, it cannot be remade.
If found, send to Sorhed (with postage prepaid)."
-- Harvard Lampoon, "Bored of the Rings"

--
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

Ignore the folding

Hi,
I use syntax folding with C++. How do I ignore the folding in my while, if and for constructs?

Best regards.
-- 
JuanPabloAJ

--
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

User command with -nargs=1

I thought defining a user command with '-nargs=1' would mean
that using more than one argument would give an error, however
I can't see a difference between nargs=1 and nargs=*.

command! -nargs=1 Test call Test('<args>')
function! Test(args)
call append('$', 'args: "' . a:args . '"')
endfunction

After sourcing the above:
:new
:Test (E471 Argument required; good)
:Test a (displays 'args: "a"'; good)
:Test a b (displays 'args: "a b"'; bad?)

I thought '-nargs=1' would give "E488: Trailing characters"
if more than one argument, and isn't "a b" two args?

Above tested with Vim 7.3.170 and 7.2.18 on Windows and Linux.

Is this something to do with allowing spaces in file names?

John

--
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

Re: How do define a default highlight for none-linked group?

On 30/04/11 03:35, Ben Schmidt wrote:
> On 30/04/11 9:52 AM, Tony Mechelynck wrote:
>> On 29/04/11 04:00, pansz wrote:
>>> hi vimmers,
>>>
>>> for linked group we can use :hi default link to set a default value, for
>>> none-linked group we can't.
>>>
>>> Suppose my script want to set the default value highlight group
>>> CursorIM. i.e. if user color scheme has set the hi CursorIM, let it be,
>>> if user color scheme has not set the highlight, my script set it to a
>>> specific value.
>>>
>>> Is it possible? or is it possible to check in script whether a highlight
>>> group already defined or not?
>>
>> What about
>> hi default CursorIM term=reverse ctermbg=green ctermfg=yellow
>> \ gui=bold guibg=green guifg=yellow
>>
>> I don't have a help tag but see line 4087 of syntax.txt (2011 Apr 06
>> for Vim 7.3).
>
> Well, the 'default' part is explained at :help :hi-default which applies
> not just to :hi-link, which is closest to it, and which the examples
> demonstrate, but it also applies to :hi with settings (as [default] is
> present in the syntax description, and there is a cross-reference to
> :help :highlight-default, a little bit below :help :colo).
>
> However, it doesn't really help in this case. CursorIM, being a built-in
> highlight group, never has "no settings" or "doesn't exist", unless you
> explicitly do :hi clear CursorIM or :hi CursorIM NONE. So using
> "default" to define CursorIM will be useless unless you expect your user
> to do one of those two things above if they want to get your default
> highlighting.
>
> Ben.
>
>
>
>

I don't do anything with it, and yet:

:hi CursorIM
E411: highlight group not found: CursorIM

The same happens with "vim -N -u NONE" or with "vim -u
/usr/local/share/vim/vim73/vimrc_example.vim" with or without --noplugin.


Best regards,
Tony.
--
Sodd's Second Law:
Sooner or later, the worst possible set of circumstances is
bound to occur.

--
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

Re: How do define a default highlight for none-linked group?

On 30/04/11 9:52 AM, Tony Mechelynck wrote:
> On 29/04/11 04:00, pansz wrote:
>> hi vimmers,
>>
>> for linked group we can use :hi default link to set a default value, for
>> none-linked group we can't.
>>
>> Suppose my script want to set the default value highlight group
>> CursorIM. i.e. if user color scheme has set the hi CursorIM, let it be,
>> if user color scheme has not set the highlight, my script set it to a
>> specific value.
>>
>> Is it possible? or is it possible to check in script whether a highlight
>> group already defined or not?
>
> What about
> hi default CursorIM term=reverse ctermbg=green ctermfg=yellow
> \ gui=bold guibg=green guifg=yellow
>
> I don't have a help tag but see line 4087 of syntax.txt (2011 Apr 06
> for Vim 7.3).

Well, the 'default' part is explained at :help :hi-default which applies
not just to :hi-link, which is closest to it, and which the examples
demonstrate, but it also applies to :hi with settings (as [default] is
present in the syntax description, and there is a cross-reference to
:help :highlight-default, a little bit below :help :colo).

However, it doesn't really help in this case. CursorIM, being a built-in
highlight group, never has "no settings" or "doesn't exist", unless you
explicitly do :hi clear CursorIM or :hi CursorIM NONE. So using
"default" to define CursorIM will be useless unless you expect your user
to do one of those two things above if they want to get your default
highlighting.

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

Re: How to get undo functionality after :bnext

On 29/04/11 22:47, Reckoner wrote:
> Hi,
>
> I'm using version 7.3 on a Windows XP machine.
>
> When editing multiple buffers, I do :bnext to get to the next buffer.
> Unfortunately, when I return to that buffer or one of the previously
> edited buffers, I can no longer "undo" the changes in the
> corresponding buffer.
>
> Is there a way to set it up so that even if I do :bnext that I can
> still undo changes when I return to the same buffer? I think what is
> automatically happening is that every time I do :bnext it is saving
> the file, and somehow that is flushing the undo list.
>
> Thanks!
>

I think that what you need is the new persistent-undo feature, which is
still considered experimental and therefore turned off by default.

See :help 'undofile'


Best regards,
Tony.
--
George Washington not only chopped down his father's cherry tree, but
he also admitted doing it. Now, do you know why his father didn't
punish him? Because George still had the axe in his hand.

--
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

Re: How do define a default highlight for none-linked group?

On 29/04/11 04:00, pansz wrote:
> hi vimmers,
>
> for linked group we can use :hi default link to set a default value, for
> none-linked group we can't.
>
> Suppose my script want to set the default value highlight group
> CursorIM. i.e. if user color scheme has set the hi CursorIM, let it be,
> if user color scheme has not set the highlight, my script set it to a
> specific value.
>
> Is it possible? or is it possible to check in script whether a highlight
> group already defined or not?

What about
hi default CursorIM term=reverse ctermbg=green ctermfg=yellow
\ gui=bold guibg=green guifg=yellow

I don't have a help tag but see line 4087 of syntax.txt (2011 Apr 06 for
Vim 7.3).


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
78. You find yourself dialing IP numbers on the phone.

--
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

RE: is there s 'toinitialupper' function?

Tim Chase wrote:
> let s=substitute(s, '\w\+', '\u\1', 'g')

The above is intended to change each word in s, making the first
letter uppercase and not changing the rest.

The search pattern needs brackets, or the \1 should be replaced.
The following works:

let s=substitute(s, '\w\+', '\u&', 'g')

John

--
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

RE: capture result of a global search

cyboman wrote:
> does anybody know if there is a way to capture the result of
> a global search in vim.

See:
http://vim.wikia.com/wiki/Copy_the_search_results_into_clipboard

John

--
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

Re: syntax highlighting colors bold text

On 29/04/11 11:33, Ben Schmidt wrote:
[...]
> P.S. I have no idea why 'term' would ever be set to "putty" on a
> non-DOS/Windows system, and am unsure about "cygwin" (does that count as
> UNIX or WIN3264 in the source code?), but that's what term_bg_default()
> in option.c does.
>
> Ben.
>
>
>

IIUC, Cygwin builds (requiring cygwin1.dll) give the following has()
results:
unix 1
win32unix 1
dos16 0
dos32 0
win16 0
win95 0
win32 0
win64 0

I suppose a native-Windows Vim could be run in a Cygwin bash terminal
but I would advise against it.


Best regards,
Tony.
--
Ginsberg's Theorem:
(1) You can't win.
(2) You can't break even.
(3) You can't even quit the game.

Freeman's Commentary on Ginsberg's theorem:
Every major philosophy that attempts to make life seem
meaningful is based on the negation of one part of Ginsberg's
Theorem. To wit:

(1) Capitalism is based on the assumption that you can win.
(2) Socialism is based on the assumption that you can break
even.
(3) Mysticism is based on the assumption that you can quit the
game.

--
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

Re: Language switching shortcuts

Kevin Steinhardt wrote:

> All, ...
>
> I'm a real noob when it comes to vim but I *am* learning. I'm
> currently writing a lot in Dutch as well as English, but not really in
> the same document. Is there a way to set let's say <F11> as a
> 'English' key and <F12> as a 'Nederlands' key, executing the commands
> below:
>
>    <F11> would do `set spelllang=en_gb` then `set spell`
>    <F12> would do `set spelllang=nl` then `set spell` also
>
> I'm not interested in localisation strings changing or my menus in
> gvim turning to Dutch; basically, just the spelllang parameter.
>
> I hope there's a way to execute more than one command with a single
> key.
>
> Cheers
> Kevin Steinhardt

Hi

Here is what I have in my ~/.vimrc to:

- toggle on/off spelling checker by pressing F8
- rotate though the spelling languages that I use
by pressing F7

Changing it to use other languages should be trivial:

if has('spell')
set spell

if has('eval')
" Rotate through languages of spelling checker.
let g:myLangIdx = 0
let g:myLangCodes = [ "en_us", "eo", "fr", "it", "br", "nl" ]
let g:myLangs = [ "language:", "lingvo:", "langue :", "lingua:",
"yezh:", "taal:" ]
function! MySpellLang()
let g:myLangIdx = g:myLangIdx + 1
if g:myLangIdx >= len(g:myLangs) | let g:myLangIdx = 0 | endif

exe "setlocal spell spelllang=" . g:myLangCodes[g:myLangIdx]
echo g:myLangs[g:myLangIdx] g:myLangCodes[g:myLangIdx]
endf

map <F7> :call MySpellLang()<CR>
imap <F7> <C-o>:call MySpellLang()<CR>
endif
map <F8> :set spell!<CR>
endif

-- Dominique

--
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

Re: Language switching shortcuts

On 04/29/2011 12:48 PM, Kevin Steinhardt wrote:
> <F11> would do `set spelllang=en_gb` then `set spell`
> <F12> would do `set spelllang=nl` then `set spell` also

For normal-mode, it's a pretty straight-forward

:nnoremap <f11> :set spellang=eng_gb spell<cr>
:nnoremap <f12> :set spelllang=nl spell<cr>

If you want to be able to toggle within insert mode, you can do
the above mixed with

:imap <f11> <c-o><f11>
:imap <f12> <c-o><f12>

or you can make explicit mappings

:inoremap <f11> <c-o>:set spellang=eng_gb spell<cr>
:inoremap <f12> <c-o>:set spelllang=nl spell<cr>

-tim


--
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

Re: capture result of a global search

On 04/29/2011 03:59 PM, cyboman wrote:
> does anybody know if there is a way to capture the result of a global
> search in vim.
>
> for example in perl i can do the following
> string =~ /(pattern1)someword/i
> and $1 will contain patter1.
>
> is something like this possible in vim scripting?

You don't mention explicitly where you want it. You can use

:redir

to capture to various locations (variables, files, registers).
You can read more at

:help :redir

Alternatively, you can append the resulting matches:

:let s ='' |g/pattern/let s += getline('.')

-tim


--
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

capture result of a global search

does anybody know if there is a way to capture the result of a global
search in vim.

for example in perl i can do the following
string =~ /(pattern1)someword/i
and $1 will contain patter1.

is something like this possible in vim scripting?

any help is appreciated

--
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

Re: How to get undo functionality after :bnext

On 04/29/2011 03:47 PM, Reckoner wrote:
> When editing multiple buffers, I do :bnext to get to the next buffer.
> Unfortunately, when I return to that buffer or one of the previously
> edited buffers, I can no longer "undo" the changes in the
> corresponding buffer.
>
> Is there a way to set it up so that even if I do :bnext that I can
> still undo changes when I return to the same buffer?

:set hidden

:help 'hidden'

-tim


--
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

How to get undo functionality after :bnext

Hi,

I'm using version 7.3 on a Windows XP machine.

When editing multiple buffers, I do :bnext to get to the next buffer.
Unfortunately, when I return to that buffer or one of the previously
edited buffers, I can no longer "undo" the changes in the
corresponding buffer.

Is there a way to set it up so that even if I do :bnext that I can
still undo changes when I return to the same buffer? I think what is
automatically happening is that every time I do :bnext it is saving
the file, and somehow that is flushing the undo list.

Thanks!

--
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

Re: syntax highlighting colors bold text

> PuTTY is often used to remotely log in to a Unix system from a
> Windows system.

Yeah. I'm a twit. Didn't think hard enough about that one. O well.

Anyway, the patch is accurate, so I still hope Bram will accept that (or
do something similar).

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

quick fix to jump between warnings and errors

the compiler and lint tool my company is using generate 3 kinds of
messages: errors, warnings and info. right now my keys are mapped in
such a way that in quick fix window i jump between warnings, errors
and info. is there a way to setup key mappings so that one key would
only jump between errors, the other between warnings and the third
between info, i.e.

map <F2> jump to the next error
map <F3> jump to the next warning
map <F4> jump to the next info.

here is what my errorformat is set to:

set errorformat=%f\(%l\)\ :\ %m,%C\ \ %p^\,%C%p~,%A\"%f\"\\,%l%m\,%C%m
\,%Z

any help is appreciated.

p.s. i not new to vim but i never really got into all the details. i
didn't come up with errorformat variable setting, my boss gave it to
me. if you could simplify the explanation i would really appreciate it.

--
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

Language switching shortcuts

All, ...

I'm a real noob when it comes to vim but I *am* learning. I'm
currently writing a lot in Dutch as well as English, but not really in
the same document. Is there a way to set let's say <F11> as a
'English' key and <F12> as a 'Nederlands' key, executing the commands
below:

<F11> would do `set spelllang=en_gb` then `set spell`
<F12> would do `set spelllang=nl` then `set spell` also

I'm not interested in localisation strings changing or my menus in
gvim turning to Dutch; basically, just the spelllang parameter.

I hope there's a way to execute more than one command with a single
key.

Cheers
Kevin Steinhardt

--
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

Re: is there s 'toinitialupper' function?

On 04/29/2011 11:55 AM, Andrew Long wrote:
> I'm writing a script where I want to capitalise the first
> letter of a word. I know hat 'toupper' will change
> lower-to-upper case on the whole string, like \U in a :s
> command, but is there an equivalent of \u (convert the initial
> character only?)

I presume you want something like

let s = capitalise(s)

instead of doing a :s sort of command. While one doesn't exist,
you can use a mashup of the two:

let s=substitute(s, '\w\+', '\u\1', 'g')

if you just want to capitalize the first letter and leave the
rest alone. If you want to lowercase the rest, you can do

let s=substitute(s, '\(\w\)\(\w*\)', '\u\1\L\2', 'g')

The difference can be seen in transforming

let s = 'myVariable'

The first form will transform it to

MyVariable

while the second form will transform it to

Myvariable

And as always, if you want it functionized, you can easily wrap
it up:

function! Capitalize(s)
return substitute(s, '\(\w\)\(\w*\)', '\u\1\L\2', 'g')
endfunction

-tim


--
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

is there s 'toinitialupper' function?

I'm writing a script where I want to capitalise the first letter of a word. I know hat 'toupper' will change lower-to-upper case on the whole string, like \U in a :s command, but is there an equivalent of \u (convert the initial character only?)

I know that I can do it by jiggering around with strpart() and len(), but I hoped that it might be simpler than that.

looking for 'initial' and 'leading in helpgrep yielded too many hits to easily scan.

TIA.

Regards, Andy
--
Andrew Long
andrew dot long at mac dot com

Re: syntax highlighting colors bold text

On 2011-04-29, Ben Schmidt wrote:

> P.S. I have no idea why 'term' would ever be set to "putty" on a
> non-DOS/Windows system, and am unsure about "cygwin" (does that count as
> UNIX or WIN3264 in the source code?), but that's what term_bg_default()
> in option.c does.

PuTTY is often used to remotely log in to a Unix system from a
Windows system.

It sets TERM to "xterm" by default, but I'm thinking about changing
that to "putty". Some highlight color combinations that look good
on a real xterm or on a GNOME Terminal look horrible on PuTTY, and
knowing which terminal I'm really using would allow my color scheme
to set better highlight colors.

Regards,
Gary

--
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

dead key bug.

Hi, all. (Sorry for the long mail).

I'm having an issue typing dead keys since last year. The issue started when I
upgrade Vim from version 6 to version 7. In that time I started a thread here
but, since the problem was not solved, I rollback to using Vim 6 again.

I thought the problem could come from an installed plugin or another Vim
script. Last month I was able to completely format my notebook and start a new
installation. I installed Vim 7 without any of my plugins or scripts but the
problem persists. Even starting Vim with '-u NONE' command line option.

The issue with the dead keys is random. That is, sometimes it happens,
sometimes not. Is difficult to predict when it will happen. I work in a
Windows XP Professional machine using ISO-8859-1 character set (cp1252 on
Windows and cp850 in a MSDOS box) the official language is Brazilian
Portuguese and I use an US International keyboard layout. The last made test
was in a notebook with official language English (United States), also using
an US International keyboard layout. In that machine the cp1252 (ISO-8859-1)
is still used in Windows but MSDOS boxes use cp437 code page. The operating
system in this notebook is a Windows XP Home. This mail was written in a
MacBook with Snow Leopard 10.6.7 and Vim 7.3. In the MacBook the problem
doesn't happen.

The problem: sometimes the dead keys like ", ', `, ~ and ^ doesn't show up.
This happens when I type this keys followed by a space. This is the default way
to get the character it self. That is, if I want to put the letter a between
single quotes I need the following key sequence: quote+space+a+quote+space.

Sometimes the quote character is not processed by Vim. But the space character
is and Vim prints a blank space in the buffer. With should not be since the
key sequence quote+space should print a ' character. Although the quote
character is not processed it's still kept in the keyboard buffer because,
when the a key is pressed, Vim prints an a acute (á), which is the result of
the sequence quote+a. The same issue happens with the other keys mentioned
above.

Well, the problem happens only in the GUI version, not in the terminal
version. That is, this only happens in GVim, not in Vim. Also the issue
happens only when I'm typing in the buffer in INSERT mode. The problem doesn't
happen when typing in the command window or in NORMAL mode.

With this knowledge I started to read all documentation about changes made in
this version and stumbled upon the 'lmap', 'keymap', 'iminsert' and 'imsearch'
options. I read all the documentation found in the 'mbyte.txt' file and
started to think that could be something it this matter. I build my own
'accents.vim' file and put it in my $RUNTIMEPATH/keymap folder. The file is
strait forward since I only needed some keys. The important part of it is:

\"<Space> \"
'<Space> '
`<Space> `
~<Space> ~
^<Space> ^

I really thought this would solve the problem but, don't. The problem
persists. Sometimes the key sequence works, sometimes don't. That's why I
think there is a Vim bug within this matter.

What I really need this time is some thoughts about how to debug Vim in a
Windows XP environment. How to download the Vim sources and what kind of debug
to use, cdb or gdb. And, if possible, in what files should I start search.

Regards,

Alessandro

--
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

Re: execute command from vim in windows

Ben Schmidt <mail_ben_schmidt@yahoo.com.au>:
> On 29/04/11 8:51 PM, Jan Larres wrote:
>>Ben Schmidt<mail_ben_schmidt@yahoo.com.au>:
>>>>One of the ways to avoid spaces in Windows names of files and
>>>>directories is to replace any "controversial" names by their 8.3
>>>>equivalents
>>>
>>>Of course, this will only work on filesystems that still support 8.3
>>>equivalents and have that functionality turned on, which isn't always
>>>the case these days. Just a potential gotcha with that approach.
>>
>>Really? Ugh. I'm using this method for my 'Tagbar' plugin to call ctags
>>(using system()) since shellescape() doesn't seem to work in Windows for
>>this case. Could you give some information about when this might be the
>>case?
>
> From what I can gather from a little Googling:
>
> - 8.3 filenames can only be disabled at all on NTFS volumes.
> - They can be disabled system-wide from Windows NT onwards.
> - They can be disabled per-volume on Windows 7.
> - They are disabled by default on Windows (Server) 2008.

Thanks! I didn't expect you to Google it for me, though, I just thought
you already knew some details :)

Now to find some other workaround ...

Jan

--
-[ OpenPGP key ID: 00A0FD5F ]-
Fashion is a form of ugliness so intolerable that we have to alter it every
six months.
-- Oscar Wilde

--
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

Re: Vi for any Windows APP using AutoHotkey

Excerpts from Marko Mahnič's message of Fri Apr 29 10:11:23 +0200 2011:
> You are free to use any part of the script.
I feel that my code already supports more than yours.

I may have a look at how you managed mapping alt-* keys though cause
that is causing troubles to me.

Thanks
Marc Weber

--
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

Re: vim to resize split windows when size of xterm's window changes

On 04/29/2011 09:26 AM, Taylor Hedberg wrote:
> There's a "VimResized" event that you can use with autocommands. I'd try
> something like this (untested):
>
> autocmd VimResized * normal!<C-W>=

There's a :wincmd command, so you should be able to just do

autocmd VimResized * wincmd =

-tim

--
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

Re: vim to resize split windows when size of xterm's window changes

There's a "VimResized" event that you can use with autocommands. I'd try
something like this (untested):

autocmd VimResized * normal! <C-W>=

--
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

vim to resize split windows when size of xterm's window changes

hi all,

i often realize that when I change the size of xterm with vim running
inside of it, i end up always pressing:

^w=

To get vim to resize all splits equally.

is there a way to get vim to do this for me once i've resized xterm?

TIA,

David

--
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

Re: quickfix window's manual fix

Hi,

The quickfix modification functions are rather difficult to use,
especially when you just want to edit one entry. For this reason I
created a vim script called editqf (http://www.vim.org/scripts/
script.php?script_id=3557
). Basically you just press "i" in the
quickfix window. A new window will be opened where you can change the
quickfix entries. When you are done, just save/close the newly created
window with :w or :x.

I hope this is helpful to you.

Greetings,

Jan Christoph

--
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

Re: ":windo g/pattern/q" peculiarity

On 04/28/2011 09:49 PM, Jean-Rene David wrote:
> * Tim Chase [2011.04.28 14:40]:
>> Because each of your files have the same number of lines, it doesn't
>> register a change. For a full example:
>>
>> bash$ cd ~/tmp; mkdir moreless; cd moreless
>> bash$ for i in 10 20 30 40 50; do seq $i> ${i}.txt ; done
>> bash$ sed -i '5s/$/@/' 30.txt
>> bash$ sed -i '10s/$/@/' 50.txt
>> bash$ vim -o *.txt
>> :windo g/@/q
>
> Got it now.
>
> The problem is that the :g command just subtracts the number of lines in
> the buffer where it starts from the number of lines in the buffer where
> it ends to produce that message.
>
> Of course it assumes those two buffers are the same but it doesn't
> *check* that it is so.

That's sorta what I figured, as I mentioned in my original post:

TKC> lines before the ":g" and comparing it to number of lines after
TKC> the ":g", and reporting the difference, but not noticing
that the
TKC> file/buffer/window had changed in the process.

Thanks for throwing together a patch.

-tim

--
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

Re: how to map 2-leftmouse to open file in netw

Ben Fritz wrote:
>
> On Apr 28, 10:09 am, wei gao<njugao...@gmail.com> wrote:
>
>> Hi,
>>
>> In netw file explorer, the click left mouse on the file/folder will open the
>> file/folder. Is there any way to use doube click to open the file/folder?
>> Left mouse is usually used to select the file/folder instead of open
>> file/folder.
>>
>>
> Two steps:
> 1. in .vimrc, add let g:netrw_mousemaps = 0 " disable single-click to
> open file
> 2. in ~/.vim/after/ftplugin/netrw.vim or similar (mine is in ~/.vim/
> after/ftplugin/netrw_maps.vim), put nmap<buffer> <2-leftmouse> <CR>
>
> Note you must use nmap instead of nnoremap, since you are
> intentionally triggering the<CR> mapping in NetRW.
>
>
FYI: this will, of course, disable _all_ mouse mappings that netrw
normally provides; please look at :help g:netrw_mousemaps for the list.

Regards,
Chip Campbell

--
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

Re: vim %


thanks for the help.

On Fri, Apr 29, 2011 at 3:48 AM, Tony Mechelynck <antoine.mechelynck@gmail.com> wrote:
On 28/04/11 15:04, cyboman wrote:
i'm trying to learn a bit of vim scripting, specifically i'm trying to
understand how to do something similar to scanf().

say we have a command

map ,cd :cd %:p:h<CR>

what do those %:p:h mean? can anyone recommend a help file i need do
read in order to understand the meanings of %:p:h?

any help is appreciated


You already got the answer of where to find the requested help, and by all means go read it: I've always liked the Vim help better than any novel.

Now: about this particular question:
       %       the current file
       :p      expanded to a full path
       :h      the "head" of the path (removing the last element)

IOW: %:p:h means "the directory of the current file". If the current "file" is actually a directory (i.e., you're in a netrw window), then %:p:h means the _parent_ of the directory being browsed.

There are other filename-modifiers than :p and :h -- the help will tell you what they are, with examples. And there are other "filename" symbols than % too:
       :help filename-modifiers
       :help cmdline-special
You could also have found the former by looking up ::p or ::h, or even %:p or %:h ; or the latter by looking up c_% -- they are actually after each other in a single chapter of one helpfile.

Note that if you're editing in split-windows mode, you may prefer to use :lcd rather than :cd in order to change only the "local" directory for the current window, without clobbering any working-directory which has been set for other windows.


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
77. The phone company asks you to test drive their new PBX system

--
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

Re: regex for special chars

On 04/29/2011 04:18 AM, sinbad wrote:
> searching for "^[[K^[[?1l^[>" using "/" works.
> but when i use the same string in :%s, it says
> the pattern is not found. how to make it recongnize
> as "/" does. or is there any way to automatically
> convert the string to equivalent regexp that :%s
> understands.

While I'm not sure what's happening, if you've already searched
with "/", you can leave the search blank in the :s command:

:%s//replacement/flags

to search for the last thing searched.

My first question would be to ask what the entire :s command is
that you're using. If there's a "]" in the replacement, it can
be seen as closing a character-class started in the search-part. E.g.

:%s/[ /&]/g

searches for the first space/slash/ampersand on the line and
replaces it with a "g". It doesn't look for all the "[ " and put
a closing "]" after them. This can be prevented by escaping
literal "[" characters (assuming that "^[" was a literal escape):

:%s/^[\[K^[\[?1l^[>/replacement/g
^ ^
Hope that gives you some leads.

-tim


--
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

Re: execute command from vim in windows

On 29/04/11 8:51 PM, Jan Larres wrote:
> Ben Schmidt<mail_ben_schmidt@yahoo.com.au>:
>>> One of the ways to avoid spaces in Windows names of files and
>>> directories is to replace any "controversial" names by their 8.3
>>> equivalents
>>
>> Of course, this will only work on filesystems that still support 8.3
>> equivalents and have that functionality turned on, which isn't always
>> the case these days. Just a potential gotcha with that approach.
>
> Really? Ugh. I'm using this method for my 'Tagbar' plugin to call ctags
> (using system()) since shellescape() doesn't seem to work in Windows for
> this case. Could you give some information about when this might be the
> case?

From what I can gather from a little Googling:

- 8.3 filenames can only be disabled at all on NTFS volumes.
- They can be disabled system-wide from Windows NT onwards.
- They can be disabled per-volume on Windows 7.
- They are disabled by default on Windows (Server) 2008.

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

Re: execute command from vim in windows

Ben Schmidt <mail_ben_schmidt@yahoo.com.au>:
>> One of the ways to avoid spaces in Windows names of files and
>> directories is to replace any "controversial" names by their 8.3
>> equivalents
>
> Of course, this will only work on filesystems that still support 8.3
> equivalents and have that functionality turned on, which isn't always
> the case these days. Just a potential gotcha with that approach.

Really? Ugh. I'm using this method for my 'Tagbar' plugin to call ctags
(using system()) since shellescape() doesn't seem to work in Windows for
this case. Could you give some information about when this might be the
case?

Thanks,
Jan

--
-[ OpenPGP key ID: 00A0FD5F ]-
There is no pleasure in having nothing to do; the fun is in having lots to
do and not doing it.
-- Mary Wilson Little

--
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

Re: regex for special chars

On 29/04/11 7:18 PM, sinbad wrote:
> hi,
>
> searching for "^[[K^[[?1l^[>" using "/" works.
> but when i use the same string in :%s, it says
> the pattern is not found. how to make it recongnize
> as "/" does. or is there any way to automatically
> convert the string to equivalent regexp that :%s
> understands.

Put backslashes before the [ which will start collections without that.
It should have them when using "/" too, but it must backtrack and 'fix'
it for you better than :s does.

^[\[K^[\[?1l^[>

\e would also be more readable than ^[, IMHO:

\e\[K\e\[?1l\e>

Mind you, I'd hardly call that readable either.

Grins,

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

Re: syntax highlighting colors bold text

Hi Ben!

On Fr, 29 Apr 2011, Ben Schmidt wrote:

> P.S. I have no idea why 'term' would ever be set to "putty" on a
> non-DOS/Windows system, and am unsure about "cygwin" (does that count as
> UNIX or WIN3264 in the source code?), but that's what term_bg_default()
> in option.c does.

Putty is available under Unix. I am not sure, how often it is used,
though.

regards,
Christian
--

--
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

Re: syntax highlighting colors bold text

On 29/04/11 1:52 PM, Ben Schmidt wrote:
>> $COLORFGBG is set for the user, but not for root.
>>
>> $ echo $COLORFGBG
>> default;default;0
>>
>> Again, thank you!
>>
>> Best regards, mih
>
> To some degree, it looks like this is rxvt-specific. From version7.txt:
>
>> When using an rxvt terminal emulator guess the value of 'background'
>> using the COLORFGBG environment variable. (Ciaran McCreesh)
>
> Suggested diff to options.txt to make this easier to troubleshoot in the
> future, Bram:
>
> --- options.txt~ 2011-04-29 13:34:22.000000000 +1000
> +++ options.txt 2011-04-29 13:49:11.000000000 +1000
> @@ -820,7 +820,13 @@
> been set.
>
> *'background'* *'bg'*
> -'background' 'bg' string (default "dark" or "light")
> +'background' 'bg' string (default for GUI: "dark" or "light", according
> + to the background color;
> + for MS-DOS, Windows and OS/2: "dark";
> + for other systems: "dark" if 'term' is
> + "linux", "screen.linux", "cygwin" or "putty",
> + or $COLORFGBG suggests a dark background,
> + otherwise "light")
> global
> {not in Vi}
> When set to "dark", Vim will try to use colors that look good on a

P.S. I have no idea why 'term' would ever be set to "putty" on a
non-DOS/Windows system, and am unsure about "cygwin" (does that count as
UNIX or WIN3264 in the source code?), but that's what term_bg_default()
in option.c does.

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

regex for special chars

hi,

searching for "^[[K^[[?1l^[>" using "/" works.
but when i use the same string in :%s, it says
the pattern is not found. how to make it recongnize
as "/" does. or is there any way to automatically
convert the string to equivalent regexp that :%s
understands.

thanks

--
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

Re: how to map 2-leftmouse to open file in netw

On 29/04/11 09:09, wei gao wrote:
> 2011/4/28 Ben Fritz <fritzophrenic@gmail.com
> <mailto:fritzophrenic@gmail.com>>
>
>
>
> On Apr 28, 10:09 am, wei gao <njugao...@gmail.com
> <mailto:njugao...@gmail.com>> wrote:
> > Hi,
> >
> > In netw file explorer, the click left mouse on the file/folder
> will open the
> > file/folder. Is there any way to use doube click to open the
> file/folder?
> > Left mouse is usually used to select the file/folder instead of open
> > file/folder.
> >
>
> Two steps:
> 1. in .vimrc, add let g:netrw_mousemaps = 0 " disable single-click to
> open file
> 2. in ~/.vim/after/ftplugin/netrw.vim or similar (mine is in ~/.vim/
> after/ftplugin/netrw_maps.vim), put nmap <buffer> <2-leftmouse> <CR>
>
> Note you must use nmap instead of nnoremap, since you are
> intentionally triggering the <CR> mapping in NetRW.
>


> It works. Thanks a lot.
> But I'm wondering why could you make sure the map only applies to netrw
> plugin? Does this has any affect to other fuctions/pluglins in VIM?
>

That's where two pieces of magic come in:

- Placing that line in ftplugin/netrw.vim means that the mapping will
only be defined when creating a netrw buffer (at its FileType event)
- The <buffer> modifier in the mapping means it will only apply to the
current buffer, other buffers won't see it.

See
:help ftplugin
:help :map-<buffer>

Best regards,
Tony.
--
"It runs like _x_, where _x_ is something unsavory"
-- Prof. Romas Aleliunas, CS 435

--
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

Re: Plugin for specific file type

On 28/04/11 17:55, Ben Fritz wrote:
>
>
> On Apr 28, 11:26 am, JuanPabloAJ<jabar...@gmail.com> wrote:
>> but, if this plugin is for many language,
>> I cant use the&ft variable ?
>>
>
> Sure you can, but that's not what you asked. You have a few options:
>
> 1. Always load the plugin for all file types by placing it in your
> ~/.vim/plugin directory, but for every feature in the plugin, make it
> do nothing unless&ft is the desired file type.
> 2. Only load the plugin for certain file types, by using the filetype
> plugin method mentioned, and copying it for every desired file type.

If it's a bulky script, you could put it someplace out of the way (let's
say, name it ~/.vim/macros/foobar.vim ) then add several one-liners to
source it: e.g. either add

runtime macros/foobar.vim

either as part or all of each of
~/.vim/ftplugin/c.vim
~/.vim/ftplugin/cpp.vim
~/.vim/ftplugin/css.vim
~/.vim/ftplugin/javascript.vim

or else place in your vimrc the single autocommand (this is method 3 below)

autocmd FileType c,cpp,css,javascript runtime macros/foobar.vim

For both of these (which correspond to methods 2 above and 3 below) your
script will be sourced once for each editfile to which it applies: so it
should use :setlocal (not :set), :lcd (not :cd), :let b:var = value (not
:let var = value) etc.

One example of the latter would be, quite near the begin of your script:

if exists('b:did_run_foobar')
finish
endif
let b:did_run_foobar = 1

to avoid sourcing the script twice for the same buffer.

> 3. Only load the plugin for certain file types, by sourcing the script
> in a FileType autocmd for the desired file types.
> 4. Some other method you may be able to think of, Vim has lots of ways
> to automatically do arbitrary things, including the sourcing of
> scripts.
>

Best regards,
Tony.
--
If God wanted us to be brave, why did he give us legs?
-- Marvin Kitman

--
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

Re: Vi for any Windows APP using AutoHotkey

On Apr 28, 6:40 pm, Marc Weber <marco-owe...@gmx.de> wrote:
> Is it possible?
> Well of course not. But with some work we can get close enough to make
> editing text much more fun. In some cases its not useful to use Vim, eg
> if you want to use existing "IDE" features of tools such as Delphi 2009.
>
> Is anyone interested in helping extending such an implementation?
>
A long time ago while I was doing all of my work on Windows I created
something similar.
It's called "Modal keyboard remapper" and can be found at
http://www.autohotkey.com/forum/topic14428.html.
(Then I moved to Linux and I've been using Vim ever since :) ).

IIRC the operation is a little bit different than Vim: first you
select a region (eg. sw), then you issue a command. The script uses a
semi-transparent window to indicate the current mode the script is in.
The last time I used it was end of 2008. I don't know how AHK has
evolved since then so the script might not work any more.

You are free to use any part of the script.

Marko

--
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

Thursday, April 28, 2011

Re: ":windo g/pattern/q" peculiarity

* Tim Chase [2011.04.28 14:40]:
> Because each of your files have the same number of lines, it doesn't
> register a change. For a full example:
>
> bash$ cd ~/tmp; mkdir moreless; cd moreless
> bash$ for i in 10 20 30 40 50; do seq $i > ${i}.txt ; done
> bash$ sed -i '5s/$/@/' 30.txt
> bash$ sed -i '10s/$/@/' 50.txt
> bash$ vim -o *.txt
> :windo g/@/q

Got it now.

The problem is that the :g command just subtracts the number of lines in
the buffer where it starts from the number of lines in the buffer where
it ends to produce that message.

Of course it assumes those two buffers are the same but it doesn't
*check* that it is so.

I have a small patch to fix that as soon as my registration on vim-dev
goes through...

--
JR

--
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

How do define a default highlight for none-linked group?

hi vimmers,

for linked group we can use :hi default link  to set a default value, for none-linked group we can't.

Suppose my script want to set the default value highlight group CursorIM. i.e. if user color scheme has set the hi CursorIM, let it be, if user color scheme has not set the highlight, my script set it to a specific value.

Is it possible? or is it possible to check in script whether a highlight group already defined or not?


--
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

RE: Few questions

> 3. How can I get vi to close out my (..), '..', {..}, and so on (this
>     might become annoying but I'd like to try something like this anyway).

I have a few simple mappings that are specific to Perl IF statements, but they could easily be modified to any structure:
 
" 1-2. Open Perl IF statement and reposition cursor (normal and insert modes)
noremap <silent><Leader>[ <ESC>aif () {<ESC><Left><Left>i
inoremap <silent><Leader>[ <ESC>aif () {<ESC><Left><Left>i
" 3. Close Perl IF statement and reposition cursor
inoremap <silent><Leader>] <ESC>o
" 4. Finish Perl IF statement and reposition cursor
inoremap <silent><Leader>' <ESC>o}<CR>
 
The first two maps (normal and insert modes) create the IF structure and reposition the cursor between the parens in insert mode to enter the condition(s).
The third map escapes from insert mode and opens a new line in insert mode to enter the statement(s) under the IF.
The fourth map escapes from insert mode, opens a new line with }, and issues a carriage return, which causes autoindent to align the closing brace.
 
The characters after the leader were chosen for convenience and proximity to each other. '[' to open the IF, ']' to close the IF, and ' to finish the IF.
Hope this helps.
 
Roy
 

Re: Few questions

On Thu, Apr 28, 2011 at 2:39 PM, Taylor Hedberg <tmhedberg@gmail.com> wrote:
> shawn wilson, Thu 2011-04-28 @ 14:08:31-0400:
>> yeah, i am going to have to play with :nmap a bit... something like:
>> :nmap <Space> i_<Esc>l_r
>> (which doesn't do it exactly, maybe a_ ...
>
> Try the following instead:
>
>    nnoremap <Space> i <Esc>r
>

that does the opposite..... got it
noremap <Space> a <Esc>r

--
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

Re: Few questions

shawn wilson, Thu 2011-04-28 @ 14:08:31-0400:
> yeah, i am going to have to play with :nmap a bit... something like:
> :nmap <Space> i_<Esc>l_r
> (which doesn't do it exactly, maybe a_ ...

Try the following instead:

nnoremap <Space> i <Esc>r

--
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

Re: ":windo g/pattern/q" peculiarity

On 04/28/2011 01:15 PM, Jean-Rene David wrote:
> * Tim Chase [2011.04.28 14:00]:
> [...]
>> :windo g/pattern/q
>>
>> which did as I expected, but had the odd side effect of printing
>> misleading messages about additional/fewer lines:
>>
>> 193 more lines
>> E486: Pattern not found: @
>> 86 fewer lines
>> 16 fewer lines
>> E486: Pattern not found: @
>
> I can't reproduce this on terminal vim 7.3.143. I had two files open:
>
> $ cat /tmp/foo
> 1+2
> @11+12
> $ cat /tmp/bar
> barou
>
> and used both '@' and '1' as patterns.
>
> I get the E486 error but not the more/less lines messages.

Because each of your files have the same number of lines, it
doesn't register a change. For a full example:

bash$ cd ~/tmp; mkdir moreless; cd moreless
bash$ for i in 10 20 30 40 50; do seq $i > ${i}.txt ; done
bash$ sed -i '5s/$/@/' 30.txt
bash$ sed -i '10s/$/@/' 50.txt
bash$ vim -o *.txt
:windo g/@/q

produces (on the stock 7.2.445 that comes with Debian Squeeze)

E486: Pattern not found: @
E486: Pattern not found: @
10 more lines
E486: Pattern not found: @
10 fewer lines

-tim


--
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

Re: why does :copy move the cursor?

On 04/28/2011 01:16 PM, Ben Schmidt wrote:
>> Fortunately, my previous location is just a control+O away for when I
>> want to be at the source location instead of the destination location.
>
> This doesn't work for me.

Hmm...I was fairly certain that I used this. It must have just
been fortunate-coincidence that the location happened to be at
the top of my jump-stack. It's not working either for me as I
remembered.

As an alternative, you might try

g;

which at least works for :m command, if not the :t command.

-tim


--
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

Re: why does :copy move the cursor?

> Fortunately, my previous location is just a control+O away for when I
> want to be at the source location instead of the destination location.

This doesn't work for me.

> I don't know of any option to change the behavior.

Me neither.

But how then, can Ctrl-O work for you and not me?

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

Re: ":windo g/pattern/q" peculiarity

* Tim Chase [2011.04.28 14:00]:
[...]
> :windo g/pattern/q
>
> which did as I expected, but had the odd side effect of printing
> misleading messages about additional/fewer lines:
>
> 193 more lines
> E486: Pattern not found: @
> 86 fewer lines
> 16 fewer lines
> E486: Pattern not found: @

I can't reproduce this on terminal vim 7.3.143. I had two files open:

$ cat /tmp/foo
1+2
@11+12
$ cat /tmp/bar
barou

and used both '@' and '1' as patterns.

I get the E486 error but not the more/less lines messages.

[...]
> The "more"/"fewer" lines likely comes from Vim noting the number of
> lines before the ":g" and comparing it to number of lines after the
> ":g", and reporting the difference, but not noticing that the
> file/buffer/window had changed in the process.

I don't understand what you mean. I don't see how the number of lines
could have changed.

--
JR

--
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

Re: syntax highlighting colors bold text

On Thu, Apr 28, 2011 at 19:54, Ben Schmidt
<mail_ben_schmidt@yahoo.com.au> wrote:
> Sorry for so many mails in quick succession!
>
>> :verbose set background?
>
> Yep; looking at the source code, it looks like the 'background' and
> 't_Co' options are to blame.
>
> And it looks like 'background' in this case must come from $COLORFGBG
> (since $TERM/'term' (T_NAME) is already known to be the same):
>
>    if (STRCMP(T_NAME, "linux") == 0
>            || STRCMP(T_NAME, "screen.linux") == 0
>            || STRCMP(T_NAME, "cygwin") == 0
>            || STRCMP(T_NAME, "putty") == 0
>            || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
>                && (p = vim_strrchr(p, ';')) != NULL
>                && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
>                && p[2] == NUL))
>        return (char_u *)"dark";
>    return (char_u *)"light";
>
> So, I guess deal with $COLORFGBG or put :set background=dark or :set
> background=light in your .vimrc and you should get you consistent results.
>
> The defaults actually use 'Light' colours, when available, but on an 8
> colour terminal, these are made bold instead. So, setting t_Co to 16 (or
> 88 or 256) would give different results (i.e. different colours, rather
> than bold, if your terminal can actually handle more than 8 colours,
> which it almost certainly can!).
>
> Let's know how it goes!
>
> Ben.

$COLORFGBG is set for the user, but not for root.

$ echo $COLORFGBG
default;default;0

Again, thank you!

Best regards, mih

--
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

Re: Few questions

Taylor, Ben, thanks.

On Wed, Apr 27, 2011 at 9:02 PM, Taylor Hedberg <tmhedberg@gmail.com> wrote:
> shawn wilson, Wed 2011-04-27 @ 10:46:20-0400:
>> 1. In visual mode how do I select to a line number? I know I can do iB
>> or whatever but if I don't want to work with the whole function I just
>> have to hold down j.
>
> Use the G command. `nG` moves the cursor to line n. So if you want to
> select from here to line 67, type `v67G`.
>

that's what i'm looking for... i'm just so used to :n that i never think of nG.

>
>> 2. How do I insert something without entering insert mode? Ie I constantly
>> find myself doing i blah <esc> just to add a space or something.
>
> There are some suggestions for inserting single characters on this page:
> http://vim.wikia.com/wiki/Insert_a_single_character. For inserting more
> than one character, entering insert mode is really the only thing that
> makes sense.
>

yeah, i am going to have to play with :nmap a bit... something like:
:nmap <Space> i_<Esc>l_r
(which doesn't do it exactly, maybe a_ ...

>
>> 3. How can I get vi to close out my (..), '..', {..}, and so on (this
>> might become annoying but I'd like to try something like this anyway).
>
> You could use a simple key mapping in your .vimrc, such as:
>
>    inoremap ( ()<Left>
>
> but that may not always do what you want. There's also
> http://www.vim.org/scripts/script.php?script_id=1849, which is probably
> a bit more robust.
>

i'll pass on the fancy scripts for this one :)
i like the inoremap command and will read on the link ben posted (and
either be good or end up having my own macros irritating me more than
laziness)

>
>> 4. Can I get the output of :shell or whatever to be inserted a(fter)
>> my cursor?
>
> Use `:r!` to read command output into your buffer. There's also
> `:{range}!` which can pipe text from your buffer through a command, and
> then replace the original text with the command output.
>

yeah :read !<stuff> was what i was looking for. however, redir looks
pretty cool. i'll have to read up on it more as i don't quite get it
yet.

--
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

Re: why does :copy move the cursor?

On 29/04/11 3:52 AM, Jean-Rene David wrote:
> Lately I've been using the Ex commands :d, :t, :m to shuffle text around
> while editing. Since the syntax of those commands require the source
> *and* destination lines, e.g.:
>
> :100copy150
>
> to copy line 100 below line 150, I wonder why my cursors is *moved* to
> line 150 after the command.
>
> I tend to use those Ex commands precisely to avoid having to navigate to
> the line I want to move. But then I end up having to navigate back to where
> I was before I entered the command.

And, annoyingly, such a movement doesn't count as a jump, and you can't
get back to where you were with ''

Is that a bug, perhaps?

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

Re: why does :copy move the cursor?

On 04/28/2011 12:52 PM, Jean-Rene David wrote:
> Lately I've been using the Ex commands :d, :t, :m to shuffle
> text around while editing.
[snip]
> I wonder why my cursors is *moved* to line 150 after the
> command.
>
> I was wondering if others had thoughts on this behavior. Is
> there a use of them where that behavior makes more sense than
> leaving the cursor where it is?

I often use the following:

:g/pattern/t.|s/./=/g

to "title-ize" (underline with a same-length row of "===") lines
matching /pattern/

I also use something like

:t$s#3/4/2011#3/18/2011

in some of my log-files to copy the current-dated log-line to the
bottom of the file and change the date.

So I can see doing either (move or not-move the cursor), and I
can see use cases for both. Vim's behavior is likely just an
artifact of "ed did it that way, and the original vi did it that
way". Fortunately, my previous location is just a control+O away
for when I want to be at the source location instead of the
destination location.

The one reason I *do* use :m and :t frequently is to swap lines
without trampling my scratch register. I could do

ddp

but it's just about as easy (and mentally hard-coded) to issue

:m+

and preserve my scratch register. Same goes for copying the
line. I could just issue

Yp

but if I want to keep my scratch-register contents, I'll just issue

:t.


> Is there a way I may have overlooked to change that behavior?

I don't know of any option to change the behavior.

Just my use-cases and thoughts on them,

-tim


--
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