Monday, January 31, 2011

Re: vimscript syntax problem

On Mon, January 31, 2011 6:20 pm, H Xu wrote:
> Hello everybody,
>
> In a vimscript file, parentheses across multi lines is highlighted as
> errors, which is shown in the attachment. Is there any way to fix this?
>
> Thanks.

This was recently discussed here. See the thread starting at
http://groups.google.com/group/vim_use/browse_frm/thread/b7a3187fee6932e8/c1d090858eaaea64?#c1d090858eaaea64

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: MkVimball doesn't work on windows

On Tue, February 1, 2011 4:59 am, Cesar Romani wrote:
> I'm using gvim 7.3.107 on Win XP with vimball v32c
>
> If I have the following file:
> --------------------
> autoload\dbext.vim
> autoload\dbext_dbi.vim
> doc\dbext.txt
> doc\dbext_gpl.dat
> plugin\dbext.vim
> --------------------
>
> and do %MkVimball! dbext
> I'm getting:
>
> ***vimball*** unable to read file<autoload\dbext.vim>
>
> but if I do gf I can read the file!
>
> I changed \ to / but the result is the same.
>
> Many thanks in advance,

What is the working directory when you edit the vimball file?
And where are your files located?

I assume, that your autoload\dbext.vim file does not exist inside your
.vim directory (as the documentation says)?

In that case, try explicitly mentioning the path where the autoload/
directory exists:
:%MkVimball! dbext .

(in this case your files autoload/... files are in the current directory).

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: 'list', :list, and 'listchars'

On Sat, January 29, 2011 10:59 am, Andy Wokula wrote:
> Am 26.01.2011 18:41, schrieb Ben Fritz:
>>> From looking at :list, it seems like it's basically supposed to print
>> the line as it would show with 'list' turned on. However, I have a few
>> questions:
>>
>> :help :list says it will use '^' for unprintable characters, and
>> additionally says "This can be changed with the 'listchars' option.
>> However, there does not seem to be any 'listchars' option controlling
>> the display of unprintable characters. What does setting 'list' do for
>> unprintable characters? Anything?
>>
>> :help :list only mentions EOL and unprintable behavior, but
>> experimentation shows that "trail", "extends", and "tab" also apply
>> from 'listchars'. "precedes" and "extends" certainly would not make
>> sense in this context, but what about "nbsp" and "conceal"?
>> Experimentation shows that these two options do not have any effect.
>> Should they? I could understand "conceal" having no effect, but I
>> would certainly expect "nbsp" to apply, since "trail", etc. all apply.
>
> Unprintable characters basically are control characters
> :h 'isprint
> Tab is a control character - when 'listchars' does not include
> 'tab:xy', then tab will be printed as '^I'.
>
> "nbsp" was added recently, maybe just forgotten to be implemented for
> :list ...
> :list is such a rarely used command ...

Here is a patch, that adds nbsp support to :list command. I leave out
conceal, as I don't think this makes sense here:

diff --git a/src/message.c b/src/message.c
--- a/src/message.c
+++ b/src/message.c
@@ -1637,8 +1637,18 @@
else if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1)
{
col += (*mb_ptr2cells)(s);
- mch_memmove(buf, s, (size_t)l);
- buf[l] = NUL;
+ if (mb_ptr2char(s) == 160 && list && lcs_nbsp != NUL)
+ {
+ int ll=0;
+ mb_char2bytes(lcs_nbsp, buf);
+ ll=(*mb_ptr2len)(buf);
+ buf[ll] = NUL;
+ }
+ else
+ {
+ mch_memmove(buf, s, (size_t)l);
+ buf[l] = NUL;
+ }
msg_puts(buf);
s += l;
continue;


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

MkVimball doesn't work on windows

I'm using gvim 7.3.107 on Win XP with vimball v32c

If I have the following file:
--------------------
autoload\dbext.vim
autoload\dbext_dbi.vim
doc\dbext.txt
doc\dbext_gpl.dat
plugin\dbext.vim
--------------------

and do %MkVimball! dbext
I'm getting:

***vimball*** unable to read file<autoload\dbext.vim>

but if I do gf I can read the file!

I changed \ to / but the result is the same.

Many thanks in advance,

--
Cesar

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

Present For You

I really like this http://ilovenihon.com/info.html Hope u too!

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

vimscript syntax problem

Hello everybody,

In a vimscript file, parentheses across multi lines is highlighted as
errors, which is shown in the attachment. Is there any way to fix this?

Thanks.

Regards,
H Xu
2011/1/31

--
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: properly yanking word/selection

Reply to message «properly yanking word/selection»,
sent 19:25:55 31 January 2011, Monday
by sgp:

> 1/ yaw (yank a word) yanks the space before the word (some times it
> doesn't); I don't want the space.
Possible suggestions here:
1. use «let @"=expand("<cword>")» (@" is a register variable, expand("<cword>")
will expand to the word under the cursor (mnemonic: *c*urrent *word*)).
2. Use «normal! yiw», it won't take a space.
3. Do «let @"=substitute(@", '^\s\+', '', '')» thus removing preceding spaces.

> 2/ bSelection is needed to tell a function that it was invoked from visual
> mode; is there a better way?
If you want to use «normal!», then no. You may use «mode()» function for <expr>
mappings, but mapping expressions are executed inside a textlock with additional
restrictions including inability to use normal. Changing registers is still
allowed, but yanking a selection without «normal!» requires much more work, for
example see my getvrange function:

"{{{3 map.getvrange
function s:F.map.getvrange(start, end)
let [sline, scol]=a:start
let [eline, ecol]=a:end
let text=[]
let ellcol=col([eline, '$'])
let slinestr=getline(sline)
if sline==eline
if ecol>=ellcol
call extend(text, [slinestr[(scol-1):], ""])
else
call add(text, slinestr[(scol-1):(ecol-1)])
endif
else
call add(text, slinestr[(scol-1):])
let elinestr=getline(eline)
if (eline-sline)>1
call extend(text, getline(sline+1, eline-1))
endif
if ecol<ellcol
call add(text, elinestr[:(ecol-1)])
else
call extend(text, [elinestr, ""])
endif
endif
return text
endfunction

It does not put anything into a register (because it was written in order to
obtain text in a given range without modifying selection, marks and registers).
It is able to obtain only characterwise range, for linewise range it will much
simpler, for blockwise range it is more complex if you want to handle
virtualedit (otherwise it is simpler). Note that I do not know a way to set a
register that includes NULL, though vim somehow preserves NULLs when using yank
commands. This function also preserves NULLs: it returns a list of strings where
NL in each string really means NULL (it is a common format for
readfile/writefile and getline/setline/append functions). Note that ecol must
point to last byte of last character, if it points to first byte (it will when
you use getpos), use

let lchar=len(matchstr(getline(eline), '\%'.ecol.'c.'))
if lchar>1
let ecol+=lchar-1
endif

This function maybe does not worth time spent on it, but it was a good trial.

Original message:
> What is the proper way to yank a word or a selection from a vim script?
> Right now I'm using if !bSelection
> normal! yaw
> else
> normal! gvy
> endif
>
> but I have some gripes:
>
> 1/ yaw (yank a word) yanks the space before the word (some times it
> doesn't); I don't want the space. 2/ bSelection is needed to tell a
> function that it was invoked from visual mode; is there a better way?
>
> TIA

Re: properly yanking word/selection

On 01/31/2011 11:25 AM, sgp wrote:
> What is the proper way to yank a word or a selection from a vim script? Right now I'm using
> if !bSelection
> normal! yaw
> else
> normal! gvy
> endif
>
> but I have some gripes:
>
> 1/ yaw (yank a word) yanks the space before the word (some times it doesn't); I don't want the space.

try yiw

-ak

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

properly yanking word/selection

What is the proper way to yank a word or a selection from a vim script? Right now I'm using
if !bSelection
normal! yaw
else
normal! gvy
endif

but I have some gripes:

1/ yaw (yank a word) yanks the space before the word (some times it doesn't); I don't want the space.
2/ bSelection is needed to tell a function that it was invoked from visual mode; is there a better way?

TIA

--
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: Dynamically adding custom colour to rgb.txt

On Jan 26, 1:53 pm, lessthanideal <geoffrey.w...@thomsonreuters.com>
wrote:
> I have a custom defined colour "0 96 255 Bob_Blue" that I
> want to use in more than one place in Windows gvim 7.3. I
> can do this by adding it to $VIMRUNTIME\rgb.txtbut that
> will be lost when I upgrade. Defining colours in other
> places has been discussed comprehensively before e.g. in
> 2005 [1], the upshot as I understand it is that you have to
> define the name inrgb.txt, the file cannot be in another
> location, but changes to it are instantly available without
> restarting vim. As far as I can tell from the help and other
> searches this is still how it works.
>
> I'm therefore thinking of having a few lines at the start of
> _vimrc that will searchrgb.txtfor my custom colour and add
> it if not present. I'm wondering if there's an obvious
> problem with doing that, or maybe I'm overlooking a better
> way to define a new colour - I can't find one?
>
> Some other ways I've considered and rejected:
> . Always use #0060FF instead of the name
> . Redefine one of my Windows system colours and use that
> . Define it as a highlight group instead of a colour per se
>
> regards,
> Geoff
>
> [1]http://vim.1045645.n5.nabble.com/How-to-solve-E254-Cannot-allocate-co...

For posterity, here is the code I have in my _vimrc for this now.
I define my own colours in $VIM\vimfiles\rgb.txt, same format as
the default rgb.txt but missing the first !XConsortium line.

" read in my colours and default colours from the files
let s:my_colours = readfile($VIM . "\\vimfiles\\rgb.txt")
let s:rgb_file = readfile($VIMRUNTIME . "\\rgb.txt")

let s:added_colours = 0
" for each of my colours
for s:my_colour in s:my_colours
let s:found=0
" for each of the default colours...
for s:line in s:rgb_file
"...found my colour?
if s:line =~ s:my_colour
let s:found=1
break
endif
endfor
"if didn't find my colour...
if s:found==0
" ... add it to the default colours
let s:rgb_file += [s:my_colour]
let s:added_colours += 1
endif
endfor
" if we changed the default colours, update the file
if s:added_colours > 0
call writefile(s:rgb_file, $VIMRUNTIME . "\\rgb.txt")
endif

regards,
Geoff

--
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: Access vim command from the lua end WAS: How do the default key commands work

On 2011-01-31 Ben Schmidt <mail_ben_schmidt@yahoo.com.au> wrote:

> > So I rephrase my question. How to access basic vim commands (here: %) from
> > inside lua? How to access an arbitrary vim function from inside lua?
>
> Use the :normal command (probably with ! to avoid using user mappings).
> E.g.
>
> :lua vim.command"normal! %"
>
> Then to get the cursor position, you can use the getpos() function. E.g.
>
> :lua mypos = vim.eval"getpos('.')"
>

Thank you very much.

Marco


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

Sunday, January 30, 2011

Re: Substitute within a highlight group.

On 01/28/2011 07:27 PM, David Fishburn wrote:

> SRSearch optionally takes parameters.
Oh.

I'v already done without srhg.

May be it will be usefull for someone. This function finds DNS zone
serial and
increments it.

function AdjustSerial()
let l:pos = getpos( '.' )
call cursor( 1, 1 )
while search( '\D\zs\d', 'W' ) > 0
if synIDattr( synID( line('.'), col('.'), 1 ), 'name' )
\ == 'zoneSerial'
s/\(\d\+\)/\=IncSerial( submatch( 1 ) )/
break
endif
endwhile
call setpos( '.', l:pos )
endfunction
function IncSerial( s )
let l:today = strftime( "%Y%m%d", localtime() )
if match( a:s, '^' . l:today ) == 0
return str2nr( a:s ) + 1
else
return l:today . '01'
endif
endfunction

--
sergio.

--
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: Access vim command from the lua end WAS: How do the default key commands work

> It's not about remapping. I'm writing a vimscript in lua. In a function I need
> the position of the opening and closing bracket. So in vim I would execute »%«
> twice. Than I have both positions. If there would be functions for the basic
> comands I just would execute the corresponding function. But apparently this
> is not the case.
>
> So I rephrase my question. How to access basic vim commands (here: %) from
> inside lua? How to access an arbitrary vim function from inside lua?

Use the :normal command (probably with ! to avoid using user mappings).
E.g.

:lua vim.command"normal! %"

Then to get the cursor position, you can use the getpos() function. E.g.

:lua mypos = vim.eval"getpos('.')"

Or something like that (I don't know Lua, and don't have the interface
compiled in, so haven't tested; but this is the idea).

Smiles,

Ben.

>
> vim 7.3 compiled with lua interpreter
>
>
> Regards
> Marco
>
>

--
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: Typing numbers

Reply to message «Re: Typing numbers»,
sent 01:55:03 31 January 2011, Monday
by adroid28:

> Thanks for the advice but I have a macbook so I wouldn't want to do that
> to it.. :) If I was using an external keyboard I would definitely do the
> painting part. I think that would help!
Instead of painting, you may use programming dvorak. It has all but two keys
different from standart us keyboard (considering only alphanumeric part of
keyboard), so having keys not black won't help you at all. It is also useful to
map CapsLock to Left Control and Left Control to Escape.

> I find though that the more customizing the less you can work on any system
> you
> happen upon and I wouldn't want that for keyboard skills...
Do you have to type fast on systems that you cannot customize? I sometimes have
to type on other systems, but it does not matter whether I will type fast or not
there. In any case, making enter short is enough for me to slow down by about
20%.

Original message:
> Wow! A lot of info!
>
> Dotan Cohen wrote:
> > I took a file to the F, J, 4, 8, F4, and F8 keys on the keyboard to
> > help find them faster. Then I painted the whole keyboard black!
> > Although painting may be a bit extreme, I do recommend filing a notch
> > into the aforementioned keys. Years later and it still saves me
> > precious seconds tens of times per day.
> >
> > If you really want to go wild on the keyboard, you can cut the silicon
> > domes inside to make the keys easier to press. That is the third thing
> > that I do to any new keyboard now (while the paint on the key caps is
> > drying, after filing notches).
>
> Thanks for the advice but I have a macbook so I wouldn't want to do that
> to it.. :) If I was using an external keyboard I would definitely do the
> painting part. I think that would help!
>
> I find though that the more customizing the less you can work on any system
> you
> happen upon and I wouldn't want that for keyboard skills...
>
> D.

Re: Typing numbers

Wow! A lot of info!


Dotan Cohen wrote:
>
>
> I took a file to the F, J, 4, 8, F4, and F8 keys on the keyboard to
> help find them faster. Then I painted the whole keyboard black!
> Although painting may be a bit extreme, I do recommend filing a notch
> into the aforementioned keys. Years later and it still saves me
> precious seconds tens of times per day.
>
> If you really want to go wild on the keyboard, you can cut the silicon
> domes inside to make the keys easier to press. That is the third thing
> that I do to any new keyboard now (while the paint on the key caps is
> drying, after filing notches).
>
>

Thanks for the advice but I have a macbook so I wouldn't want to do that
to it.. :) If I was using an external keyboard I would definitely do the
painting part. I think that would help!

I find though that the more customizing the less you can work on any system
you
happen upon and I wouldn't want that for keyboard skills...

D.
--
View this message in context: http://vim.1045645.n5.nabble.com/Typing-numbers-tp3361514p3363830.html
Sent from the Vim - General mailing list archive at Nabble.com.

--
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: Scrolling screen lines, I knew, it's impossible.

Ben Schmidt wrote:

> >> On 27/01/11 3:38 AM, oCameLo wrote:
> >>> There's so many questions and feature requests about use mouse to
> >>> scroll screen lines, but until now, it's still impossible.
> >>
> >> Bram, you're not opposed to this kind of feature, are you? So if I did
> >> some work on it, it could be included in Vim at some stage, right?
> >
> > This is a change that has a high probablity of introducing new bugs.
>
> True, though if coded carefully, these bugs should only appear when the
> feature is turned on.
>
> > There are also a few questions about how to allow the user to access
> > this, with an option setting or with different scroll commands?
> > Probably a setting, so that it can work with scrollbars.
>
> I think it would probably be best to do this in stages:
>
> 1. Add new commands to scroll one screen line at a time. Test it out,
> including by mapping the scrollwheel to those new commands in the X
> GUIs. This shouldn't be too hard, as Vim can already display lines
> starting part way through; it just usually doesn't. The experience
> wouldn't be very smooth yet either, but screen-line scrolling would at
> least be possible, and it would pave the way for something better.
>
> 2. Add an option to make scrolling work with screen lines. The meaning
> of this option would be to affect all scrolling. To start with, though,
> just make it change the meaning of the scroll wheel in X GUIs (already
> implemented), and where easy, the clicks of the scroll bar arrows. It
> might not affect Windows yet; it depends how the scrolling works there,
> and I haven't looked in any detail.
>
> 3. Make other parts of Vim, such as moving line-to-line, vertical jumps,
> and scrolling for scrolloff honour the new option, too, choosing window
> positions that begin with partial lines. This would make the editing
> experience pretty smooth.
>
> 4. Update the code for scrollbars more thoroughly, so that dragging the
> bar can work with screen lines, too. Windows should definitely benefit
> by this stage and the feature would basically be finished.
>
> 5. Pick the nits of little bugs that we can't foresee.
>
> What do you think? Would this be an OK way to proceed?

Sounds good.

--
"The question of whether computers can think is just like the question
of whether submarines can swim." -- Edsger W. Dijkstra

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
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: Delete, add 16, and insert

Then you may have some plugin remapping <C-a>? Try doing
   execute "normal! 16\<C-a>"
and see whether it helps. There is a known (and fixed in vim-7.3.100) bug that
count is not passed to plugins in normal commands.

Yup I must have some plugin that is doing that (the execute worked just fine).  I updated to a newer build of 7.3 and it worked as expected.  Much appreciated!

~Adam~

--
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: Delete, add 16, and insert

Reply to message «Re: Delete, add 16, and insert»,
sent 23:26:19 30 January 2011, Sunday
by Adam:

Then you may have some plugin remapping <C-a>? Try doing
execute "normal! 16\<C-a>"
and see whether it helps. There is a known (and fixed in vim-7.3.100) bug that
count is not passed to plugins in normal commands.

Original message:
> > What you want is to enter the ^A literally which can be done by prefixing
>
> > it with control+V:
> Oh sorry yeah that's what I did do (^V^A) I guess I left it out. When you
> do that it appears that it's only incrementing by 1 though instead of the
> prefix that you give it (16 in this case)
>
> ~Adam~

Re: Delete, add 16, and insert

On 01/30/11 14:26, Adam wrote:
>> What you want is to enter the ^A literally which can be done
>> by prefixing it with control+V:
>
> Oh sorry yeah that's what I did do (^V^A) I guess I left it
> out. When you do that it appears that it's only incrementing
> by 1 though instead of the prefix that you give it (16 in this
> case)

Good then, just wanted to make sure you weren't being surprised
by the behavior...I just tested it with a simple file with rows
of numbers and it worked with the [count] prefix:

:g/^\d/norm 16^A

(with the ^A as described). I also tested against the OP's data
and it worked for me.

Additionally, in my test case (with numbers on each line), you
can just use the :norm command with the range as detailed at

:help :normal-range

and just issue

:%norm 16^A

(if any lines shouldn't be incremented, using a smarter :g
command would be better)

-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: Delete, add 16, and insert

What you want is to enter the ^A literally which can be done by prefixing it with control+V:

Oh sorry yeah that's what I did do (^V^A) I guess I left it out.  When you do that it appears that it's only incrementing by 1 though instead of the prefix that you give it (16 in this case)

~Adam~

--
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: Delete, add 16, and insert

On 01/30/11 12:46, Adam wrote:
> :g/^\d/norm 16(press control-a) I tried just going :norm 16^A but that also
> doesn't work (they both just increment the number by 1). I know that
> pressing 16^a in normal mode works correctly so that isn't the problem.

If you only pressed ^A then it wasn't part of the command, but
rather an instruction to vim to auto-complete with all matching
patterns:

:help c_CTRL-A

What you want is to enter the ^A literally which can be done by
prefixing it with control+V:

:g/^\d/norm 16^V^A

which will appear as

:g/^\d/norm 16^A

as detailed at

:help c_CTRL-V

Hope that makes sense,

-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: Delete, add 16, and insert

I'm curious why this doesn't work:

:g/^\d/norm 16(press control-a)  I tried just going :norm 16^A but that also doesn't work (they both just increment the number by 1).  I know that pressing 16^a in normal mode works correctly so that isn't the problem.

~Adam~

--
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: Access vim command from the lua end WAS: How do the default key commands work

On 2011-01-30 Tim Chase <vim@tim.thechases.com> wrote:

> If you want a catalog of the functionality, you can look at
> things like
>
> [...]
>
> or more generically:
>
> :h index.txt

Nice list I didn't know before.

> They're available "natively" from within a "noremap" version of a
> mapping. So if you want to swap the functionality of "j" and "k"
> (wow, that would get annoying, but it's a good example), you can use
>
> :nnoremap j k
> :nnoremap k j
>
> If you didn't use the "nore" version, then the 2nd one would
> produce a recursive mapping:
>
> :nmap j k " now both j & k act like k
> :nmap k j " now k calls j calls k calls j calls k...boom
>
> Hope this makes sense. There's no underlying function (like I
> understand Emacs has) accessible to which keys can be rebound.

Thanks for the explanation.

It's not about remapping. I'm writing a vimscript in lua. In a function I need
the position of the opening and closing bracket. So in vim I would execute »%«
twice. Than I have both positions. If there would be functions for the basic
comands I just would execute the corresponding function. But apparently this
is not the case.

So I rephrase my question. How to access basic vim commands (here: %) from
inside lua? How to access an arbitrary vim function from inside lua?

vim 7.3 compiled with lua interpreter


Regards
Marco


--
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: Typing numbers

On Fri, Jan 28, 2011 at 16:18, adroid28 <d.athinaios@gmail.com> wrote:
>
> Hi all :)
>
> I am fairly new in vim and also my touch typing is not that great.
> Although I can deal very well with all the vim commands I found my self
> always looking down when I need to write a number argument. I was
> wondering wether there is a way in vim to input numbers without leaving
> the home row. Or is it that with time I will be able to reach the numbers
> row without looking?
>

I took a file to the F, J, 4, 8, F4, and F8 keys on the keyboard to
help find them faster. Then I painted the whole keyboard black!
Although painting may be a bit extreme, I do recommend filing a notch
into the aforementioned keys. Years later and it still saves me
precious seconds tens of times per day.

If you really want to go wild on the keyboard, you can cut the silicon
domes inside to make the keys easier to press. That is the third thing
that I do to any new keyboard now (while the paint on the key caps is
drying, after filing notches).

Keyboard pictures upon request.


--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

--
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: Typing numbers

On 01/30/11 04:52, John Little wrote:
>> There's only so much can fit under my skull..
>
> I don't believe that limit is relevant; there's only a few
> hundred vim commands, if you use them you'll remember them.

Now settable *options* ... ;-)

-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 do the default key commands work

On 01/30/11 03:25, Marco wrote:
> there are just the definded mappings listed, not the basic
> built-in commands like »%«, »e« or »w«.

The natively functionality for these is defined in C functions
and mapped in Vim's source-code.

If you want a catalog of the functionality, you can look at
things like

:help normal-index
:h visual-index
:h insert-index
:h ex-cmd-index
:h ex-edit-index

or more generically:

:h index.txt

They're available "natively" from within a "noremap" version of a
mapping. So if you want to swap the functionality of "j" and "k"
(wow, that would get annoying, but it's a good example), you can use

:nnoremap j k
:nnoremap k j

If you didn't use the "nore" version, then the 2nd one would
produce a recursive mapping:

:nmap j k " now both j & k act like k
:nmap k j " now k calls j calls k calls j calls k...boom

Hope this makes sense. There's no underlying function (like I
understand Emacs has) accessible to which keys can be rebound.

-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: Help, please

On 01/29/11 19:07, Ed Bradford wrote:
> I use DropBox. I edit a file on computer "A" and FORGET to
> exit vim. Now on computer "B", the .swp file prevents me from
> editing. I know I can ignore and just to go computer. However,
> VIM and DropBox could solve my problem by having an option to
> update on 1,4,16,64,256 second intervals and abandoning the
> lock file that is the .swp file. DropBox has solved the SYNC
> problem. Please embrace it and make DropBox and VIM work as
> people WANT, not as developer's expect.

While I suspect that's not what most vim users want, vim does
already supply the ability to live dangerously without a net if
you want. You can tweak the following options:

:help 'updatetime'
:h 'updatecount'
:h 'swapfile'
:h CursorHold

So you can instruct vim to auto-save the swap-file every N
seconds, every M keystrokes, or to not write a swap-file at all.
This does open you to the possibility of writing data you
*don't* want. You can see an example at

http://vim.wikia.com/wiki/Auto-save_current_buffer_periodically

Another alternative: I know a number of folks on the list
(myself included) who use vim within a session of "screen" so we
can reattach not just a running session of vim, but any console
applications from anywhere we have a SSH (or telnet, yuck)
connection to our boxes. Not quite the same, but a very powerful
tool to have in your arsenal.

As an aside, I'm not sure if English is your first language, but
your demanding "make vim work how I want, not how you want, even
though it's a rare edge-case" tone doesn't win you any points.

-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: Typing numbers

In the spirit of this thread, I'll bite...

Chris said:
> There's only so much can fit under my skull..

I don't believe that limit is relevant; there's only a few hundred vim
commands, if you use them you'll remember them.

> ... and I prefer to stick with a limited subset of keyboard actions
> that may not be the quickest and most efficient for all occasions..
> but that I can use without hesitation or incurring any overhead
> rememberiing.

Use more commands often enough and you'll use them without hesitation
also.

> Clever is not always better..

True, but vim really rewards being open to cleverness. From
http://www.moolenaar.net/habits.html:
"If you think like this, you will get stuck in the stone age of
computing. Some people use Notepad for everything, and then wonder why
other people get their work done in half the time... "

Read the rest of that article for some balance on this.

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

Invitation to connect on LinkedIn

I'd like to add you to my professional network on LinkedIn.

- Yang

Yang Zhou
Video Codec Software Engineer at Polycom


Confirm that you know Yang
After connecting with Yang, check out:
Kenneth Jordan
BGS Associates
Stephen LaCount
LaCount Law
Hugo Ahlenius
Nordpil
© 2011, LinkedIn Corporation

Re: Basic scripting question

Christian Brabandt <cblists@256bit.org> [11-01-30 10:40]:
> Hi meino.cramer!
>
> On So, 30 Jan 2011, meino.cramer@gmx.de wrote:
>
> > this is a very basic question ... I am currently learning vim
> > scripting.
> >
> > With getline(.) I can get the contents of a line of a buffer.
> >
> > But: i
> > How can I replace a line in the buffer with another contents?
>
> Use setline() or first delete its contents and then paste your buffer in
> there.
>
> > How can I delete a line completly so it become an empty one or
> > vanishes?
>
> Use the normal dd command
> or use the :d _ command
> or use setline('.', '')
>
> > How can I insert a line at a certain point?
>
> Use the append() or setline function calls.
>
> > How can a define the position in the text where this all will happen?
>
> position the cursor somewhere using cursor() or setpos(). Alternatively,
> if you use setline() or append(), they take as argument, on which line
> to operate.
>
>
> Mit freundlichen Grüßen
> 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
>

Hi Christian,

thanks for your help! :)

"setline()" seems to be the swiss army knife for me... ;)

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: Basic scripting question

Hi meino.cramer!

On So, 30 Jan 2011, meino.cramer@gmx.de wrote:

> this is a very basic question ... I am currently learning vim
> scripting.
>
> With getline(.) I can get the contents of a line of a buffer.
>
> But: i
> How can I replace a line in the buffer with another contents?

Use setline() or first delete its contents and then paste your buffer in
there.

> How can I delete a line completly so it become an empty one or
> vanishes?

Use the normal dd command
or use the :d _ command
or use setline('.', '')

> How can I insert a line at a certain point?

Use the append() or setline function calls.

> How can a define the position in the text where this all will happen?

position the cursor somewhere using cursor() or setpos(). Alternatively,
if you use setline() or append(), they take as argument, on which line
to operate.


Mit freundlichen Grüßen
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: How do the default key commands work

On 2011-01-30 meino.cramer@gmx.de wrote:

> for those keys, for which is true, that they are mapped to a function
> call try using
>
> :map

Thanks. I was aware of this command. But there are just the definded mappings
listed, not the basic built-in commands like »%«, »e« or »w«.

Marco


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

Saturday, January 29, 2011

Basic scripting question

Hi,

this is a very basic question ... I am currently learning vim
scripting.

With getline(.) I can get the contents of a line of a buffer.

But: i
How can I replace a line in the buffer with another contents?
How can I delete a line completly so it become an empty one or
vanishes?
How can I insert a line at a certain point?
How can a define the position in the text where this all will happen?

Thank you very much for any help in advance!
Have a nice weekend!
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: Delete, add 16, and insert

On Jan 29, 2011, at 9:55 PM, Colin Beighley wrote:

> Hello,
>
> I am wondering if there is a way, using some (range)s/// command, to take
>
> 0 : blah blah blah
> 1 : blah blah blah
> 2 : blah blah blah
> .
> .
> .
> 15 : blah blah blah
>
> and, line by line, delete the number and replace it with itself plus 16.

:%s/^\d\+/\=submatch(0)+16/

See :h sub-replace-\=

Israel

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

Delete, add 16, and insert

Hello,

I am wondering if there is a way, using some (range)s/// command, to take

0 : blah blah blah
1 : blah blah blah
2 : blah blah blah
 .
 .
 .
15 : blah blah blah

and, line by line, delete the number and replace it with itself plus 16.

Thanks,
Colin

--
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 the default key commands work

Marco <netuse@lavabit.com> [11-01-30 01:55]:
> Hi,
>
> I have some basic questions about how things work in vim.
>
> Is it true that every key command executes a function? Say the key command »%«
> performed on a bracket jumps to the matching closing bracket. Is there a
> function defined like MatchBracket()? If this is true, how can I see which key
> command executes which function?
>
> Regards
> Marco
>
>
> --
> 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
>

Hi Marco,

for those keys, for which is true, that they are mapped to a function
call try using

:map

after entering that press <RETURN> and you will get a list of
mappings. From left to right he columns listed are show the mode
for which the particular mapping is valid, then the key or combination
of keys and last but not least the name of the function which get
called.

HTH! :)

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

Help, please

I use DropBox. I edit a file on computer "A" and FORGET to exit vim. Now on computer "B",
the .swp file prevents me from editing. I know I can ignore and just to go computer. However, VIM
and DropBox could solve my problem by having an option to update on 1,4,16,64,256 second intervals
and abandoning the lock file that is the .swp file. DropBox has solved the SYNC problem. Please embrace
it and make DropBox and VIM work as people WANT, not as developer's expect.

Ed Bradford
egbegb2 AT gmail DOT com

--
It is impossible to rightly govern a nation without God and the Bible.
George Washington

--
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 the default key commands work

Hi,

I have some basic questions about how things work in vim.

Is it true that every key command executes a function? Say the key command »%«
performed on a bracket jumps to the matching closing bracket. Is there a
function defined like MatchBracket()? If this is true, how can I see which key
command executes which function?

Regards
Marco


--
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: Show method name in gutter

Someone on the list pointed me to this:


I use StlShowFunc for this; see  http://mysite.verizon.net/astronaut/vim/index.html#STLSHOWFUNC


I have not used it.


I follow you on "blogs"...so will be interesting to see what comes out.


-- 

Robert

Re: Starting out with VIM and C++

> I just started an introductory course on C++, and I would like to take the
> time to use VIM as an IDE. What do I need to do to get colored syntax and
> make it more usable for C++ programming?

Nick,

Since you are new to C++, you are likely to write mostly single-file
console/terminal programs. For this kind of work, I would modestly
recommend my own :) plug-in Side-C (script #2434).

It's a very simple gvim IDE for at least Linux and Windows that
transparently invokes the compiler, opens/closes the quickfix
(i.e. error message) window as necessary, runs the executable
program in several modes, and does several other useful things.

I myself happily use it on a daily basis so it must be good enough :)

Boyko

--
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: 'list', :list, and 'listchars'

Am 26.01.2011 18:41, schrieb Ben Fritz:
>> From looking at :list, it seems like it's basically supposed to print
> the line as it would show with 'list' turned on. However, I have a few
> questions:
>
> :help :list says it will use '^' for unprintable characters, and
> additionally says "This can be changed with the 'listchars' option.
> However, there does not seem to be any 'listchars' option controlling
> the display of unprintable characters. What does setting 'list' do for
> unprintable characters? Anything?
>
> :help :list only mentions EOL and unprintable behavior, but
> experimentation shows that "trail", "extends", and "tab" also apply
> from 'listchars'. "precedes" and "extends" certainly would not make
> sense in this context, but what about "nbsp" and "conceal"?
> Experimentation shows that these two options do not have any effect.
> Should they? I could understand "conceal" having no effect, but I
> would certainly expect "nbsp" to apply, since "trail", etc. all apply.

Unprintable characters basically are control characters
:h 'isprint
Tab is a control character - when 'listchars' does not include
'tab:xy', then tab will be printed as '^I'.

"nbsp" was added recently, maybe just forgotten to be implemented for
:list ...
:list is such a rarely used command ...

--
Andy

--
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 replace "\" to "\\"

Am 27.01.2011 03:51, schrieb Wayne Young:
> Hi Andy,
>
> I can understand the pattern ifys0325 gave now (thanks ifys0325!) ,
> but yours really scared me... All I can know is the last one with a
> "\=". The first one seems to be: find a "\\*", without a "\" ahead,
> and without a "\\" followed?
> And the second one: no "\" leads, but followed by a "\", and it
> matches "\\*" ?
>
> I think I may wrong to parse those two, but I am not able to
> understand them at all...
>
> On Thu, Jan 27, 2011 at 5:03 AM, Andy Wokula<anwoku@yahoo.de> wrote:
>
>> Am 26.01.2011 07:34, schrieb Wayne Young:
>>
>> Thanks very much. The second works!
>>> I am still wondering how it work. It seems to replace the "
>>> \%(\\\)\@<!\\\$(\\\)\@! " part to "\\\\". Would you help to explain
>>> the meaning of the replaced part?
>>
>> What about '\\\', the given substitute will not turn it into '\\\\'.

With spaces to make it readable:

First command:

:%s/ \\ \@<! \%( \\ \\ \) * \\ \\ \@! / \\ & / g

works as follows.
Find an odd number of backslashes (one or more):

\%( \\ \\ \) * \\

The above will find '\\\' at the start of '\\\\' (which is bad); make
sure no '\' follows the match:

\%( \\ \\ \) * \\ \\ \@!

Now the above will find '\\\' at the end of '\\\\' (after backtracking,
the next try starts one position to the right); make sure no '\'
precedes the match:

\\ \@<! \%( \\ \\ \) * \\ \\ \@!

Eventually, '\','\\\',... are found and '\\','\\\\',... are skipped.

The replace part is: a backslash plus the whole matched text.


Second command:

:%s/ \\ \@<! \%( \%( \\ \\ \) * \) \@> \\ / \\ & / g

This one makes use of \@> (rarely to be found in patterns).

Find an odd number of '\':

\%( \%( \\ \\ \) * \) \@> \\

The above will find '\\\', but not at the start of '\\\\', because
'\\\\' is matched by \%( \\ \\ \) * and the surrounding \@> disables
backtracking (which would allow a match for the following \\ ).

Now when the whole pattern (so far) fails, the next try starts one
position to the right, allowing a match for '\\\' at the end of '\\\\'.
Like with the first command, this is avoided with \\ \@<! .


Third command:

:%s/ \\ \\ \= / \\ \\ / g

This one processes each encountered backslash, no problem with
backtracking then.


Get help:

:h pattern
:h /\@!

:h sub-replace-special

etc.

--
Andy

--
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]: Help with constructing error format string....

Excerpts from vijay's message of Sat Jan 29 09:02:10 +0100 2011:
> set efm=%W\[[0-9A-Z]*]\\s%#\\S%#\\s%#\\S%#\\s%#%f\\s%#%l\\s%#[0-9]s%#
> %m

You need scanf like expressions. Don't ask me why - this seems to work:

set efm=%*[^\ ]%*[\ ]%*[^\ ]%*[\ ]%*[^\ ]%*[\ ]%*[^\ ]%*[\ ]%f\ %l%m

match no spaces:
%*[^\ ]
match spaces:
%*[\ ]

repeat until path is expected...

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

[VIM]: Help with constructing error format string....

Hi,
My compiler produces single line error strings of the form
ID Rule Alias Severity
File Line Wt Message
e.g

[4FD9] ErrorType ErrorName Error /path/to/file.ext
332 10 error message

where 332 is the line number and 10 is error severity level
The Issue is that the formatting results in variable number of spaces
between each element.
I would like to Display just the error message in the status line in
quickfix mode
The error format written by me to capture the above string is

set efm=%W\[[0-9A-Z]*]\\s%#\\S%#\\s%#\\S%#\\s%#%f\\s%#%l\\s%#[0-9]s%#
%m

but this results in displaying the entire line without going to the
file in question.
Any Idea on what I am doing wrong?
Regards
Vijay
PS:

--
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, January 28, 2011

how to add all files found in :vimgrep to arglist?

I use Vim7.3.107, now when I use :vim command:
:vim /foo/ **.c

it no longer load all file into buffer list. it makes :vim command
faster, but now I can not use a single bufdo command to process all
these file. how to add these result file into some space to make I can
use a single xxxdo (maybe bufdo or argdo) to process all these file?

thx all guys here :-)

--
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: Indpendant position marks for scripts ?

Ben Schmidt <mail_ben_schmidt@yahoo.com.au> [11-01-29 06:24]:
> On 29/01/11 3:42 PM, meino.cramer@gmx.de wrote:
> >
> >Hi,
> >
> >I want to process a text with script.
> >The text contains of two regions:
> >The first region contains of lines beginning with keyword_a
> >and the second one start with keyword_b.
> >I want to sort the first region using sort with pattern_a and
> >after that I want to sort the second region with pattern_b.
> >
> >I can set the start of the forst sort with
> >
> > : /keyword_a
> >
> >in the script. But I dont know how to limit the range of the first
> >sort so that only lines starting with keyword_a are sorted using
> >pattern_a. Same goes for the second region...
>
> Try something like
>
> :0/^a/,/^\(a\)\@!/sort
>
> It means loosely:
>
> : - perform an ex command
> 0 - from before the beginning of the file
> /^keyword_a/ - find a line beginning with 'keyword_a'
> , - and operate until
> / - we find
> ^ - the beginning of a line
> \(keyword_a\)\@! - where 'keyword_a' doesn't match
> /sort - with the sort command
>
> 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
>

Hi Ben,

...got some problems here...may be due to a not-so-exact description
of what I need...

I will try to explain... ;)

The file in its original version looks like this ( there is additional
text following keyword_[ab], which I left out here, but makes the
final
sort /<pattern>/
necessary).

something
different
fnord
foo
baz
gnu
keyword_a
noordszki
looping
tatdat
drool
socket
pipe
Unix
tools
cryptic
other-pipe
other-Unix
other-tools
other-cryptic
keyword_a
keyword_a
keyword_a
keyword_b
keyword_b
keyword_a
keyword_a
keyword_a
keyword_b
keyword_a
keyword_a
keyword_a
keyword_b
keyword_a
keyword_b
keyword_b

after the file is loaded, my script does a

:gg
:/keyword_a
:.,$sort

this way the file becomes

something
different
fnord
foo
baz
gnu
keyword_a
noordszki
looping
tatdat
drool
socket
pipe
Unix
tools
cryptic
keyword_a
keyword_a
keyword_a
keyword_a
keyword_a
keyword_a
keyword_a
keyword_a
keyword_a
keyword_a
keyword_b
keyword_b
keyword_b
keyword_b
keyword_b
keyword_b

:/^keyword_a/,/^\(keyword_a\)\@!/sort /<pattern>/

This line triggers an error saying: E493 Backward range given.

I looked into the help, which says that start and end of the range are
swapped and -- if the command is preceeded with :silent the start and
end will be automagically swapped.
I did this.

Now no error is given anymore but the the script does not work --
the sort of the above line ignores its /<pattern>/.

I have simply no glue :) what is happening here...

Thank you very much in advance for any enlightment! :)

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: Starting out with VIM and C++

> Hey Nick,
>
> If you are relatively new to vim, I suggest that you start using the
> inbuilt help (:help) as much as possible.
>
> There a couple of plugins that might make writing code a lot easier:
> 1. Nerd Tree
> 2. Nerd Commenter
> 3. Matchit
> 4. Surround.vim
> 5. Syntastic
> 6. Pyclewn
>
> (google for them, or search on vim's site)
>
> I have not used pyclewn myself; I am mostly into Ruby. It might be
> advantageous for you considering you are doing C++.
>
> P.S. : Have a look at Bram's article called "Seven Habbits of
> Effective Text Editing" [1] if you have some time.
>
> [1] http://www.moolenaar.net/habits.html

I don't use all of the following, but mentioning some more good ones,
so that it kind of documents itself (one could search the archive):
1. FuzzyFinder (must have :))
2. Fugitive
3. Command-T
4. pastie
5. camelcasemotion

--
Anurag Priyam
http://about.me/yeban/

--
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: Starting out with VIM and C++

> I just started an introductory course on C++, and I would like to take the
> time to use VIM as an IDE. What do I need to do to get colored syntax and
> make it more usable for C++ programming?

Hey Nick,

If you are relatively new to vim, I suggest that you start using the
inbuilt help (:help) as much as possible.

There a couple of plugins that might make writing code a lot easier:
1. Nerd Tree
2. Nerd Commenter
3. Matchit
4. Surround.vim
5. Syntastic
6. Pyclewn

(google for them, or search on vim's site)

I have not used pyclewn myself; I am mostly into Ruby. It might be
advantageous for you considering you are doing C++.

P.S. : Have a look at Bram's article called "Seven Habbits of
Effective Text Editing" [1] if you have some time.

[1] http://www.moolenaar.net/habits.html

--
Anurag Priyam
http://about.me/yeban/

--
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: Typing numbers

On Fri, Jan 28, 2011 at 11:28:27PM EST, Ben Schmidt wrote:

>> [*] you can add more than one character, so if you wanted, you could
>> get fancy with something like
>>
>> 40i-=<esc>
>>
>> to get a nice row of 80 characters like "-=-=-=-...=-=-=-=" but again
>> you then have to do the math and divide down. Not grievous, but I can
>> count the real-world times I've done that on one hand.

This has a flavor of déja-vu, Tim.. The more I think about it, the more
it sounds like it was you who gave out this tip initially.. I thought..
nice.. and then was never able to remember it properly.

> Or you can start taking down a receipt number without pushing i, as I
> did last week. I typed 1011 before realising it hadn't appeared on the
> screen. So then I pushed i and typed the whole 13-digit number, and when
> I hit <Esc> I got 1011 copies of it, all running together as I had typed
> no spaces or newlines or anything. Brilliant! There's 12 KB right there!
>
> Was that too off-topic?

Well, the OP certainly appears to have lost interest.. if that's anything
to go by.. :-)

cj

--
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: Typing numbers

On 01/28/2011 10:53 PM, Chris Jones wrote:
> On Fri, Jan 28, 2011 at 05:35:02PM EST, Tim Chase wrote:
>>> I concur that prefixing Vim normal mode commands with a count, such as
>>> '7dw' to delete the next seven words is ineffective.. Something like
>>> 'dw....' where you delete the next word (dw) and repeat the last command
>>> (.) a number of times is the way I normally do it because I don't have
>>> to count the words before I even start deleting. While I hit the dot (.)
>>> repeatedly, I can see what I'm deleting and I know when to stop.. And
>>> I can always hit 'u' for undo to bring back the words I deleted one at
>>> a time in the event I got carried away.
>>
>> This breaks when using t/T with ";" to repeat the motion as it just finds
>> the same one you just found. I have to break down and count for those :)
>
> Another reason why I don't use t/T (and don't care much for f/F either).
>
> There's only so much can fit under my skull.. and I prefer to stick with
> a limited subset of keyboard actions that may not be the quickest and
> most efficient for all occasions.. but that I can use without hesitation
> or incurring any overhead rememberiing. Namely that if the cursor is at
> the beginning of the line above and I want to get to the '..ii..' typo
> in 'rememberiing.', I find it considerably more effective when all is
> told to just hit 'w' till I get to the beginning of the word
> 'rememberiing'.. and either hit llll.. or hit 'e' to get to the end of
> the word and then 'hh' followed by 'x' to delete the last of the two

I used to do this and really hated it. I'm using ',' as leader for
mappings but if you don't, it's much easier, imho, to hit 'fi', then
hit ';' as many times as needed and then use ',' if you overshoot it.
Much fewer keystrokes than using 'w' in most cases.

But I mostly prefer to use a small function I wrote that jumps to 25%,
50% and 75% of current line (not including leading/trailing spaces) in
combination with motpat plugin mappings that make 'w' and 'b' commands
go to the next word ignoring punctuation. I use my function to jump
to closest spot to where I want to go and then it's either 'w', 'b', 'f'
or 't'. In 99% of cases I only need 2 keystrokes.

-ak

--
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: Indpendant position marks for scripts ?

Ben Schmidt <mail_ben_schmidt@yahoo.com.au> [11-01-29 06:24]:
> On 29/01/11 3:42 PM, meino.cramer@gmx.de wrote:
> >
> >Hi,
> >
> >I want to process a text with script.
> >The text contains of two regions:
> >The first region contains of lines beginning with keyword_a
> >and the second one start with keyword_b.
> >I want to sort the first region using sort with pattern_a and
> >after that I want to sort the second region with pattern_b.
> >
> >I can set the start of the forst sort with
> >
> > : /keyword_a
> >
> >in the script. But I dont know how to limit the range of the first
> >sort so that only lines starting with keyword_a are sorted using
> >pattern_a. Same goes for the second region...
>
> Try something like
>
> :0/^a/,/^\(a\)\@!/sort
>
> It means loosely:
>
> : - perform an ex command
> 0 - from before the beginning of the file
> /^keyword_a/ - find a line beginning with 'keyword_a'
> , - and operate until
> / - we find
> ^ - the beginning of a line
> \(keyword_a\)\@! - where 'keyword_a' doesn't match
> /sort - with the sort command
>
> 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
>

Hi Ben,

GREAT! Thanks a lot! That helps me much!

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: Indpendant position marks for scripts ?

On 29/01/11 3:42 PM, meino.cramer@gmx.de wrote:
>
> Hi,
>
> I want to process a text with script.
> The text contains of two regions:
> The first region contains of lines beginning with keyword_a
> and the second one start with keyword_b.
> I want to sort the first region using sort with pattern_a and
> after that I want to sort the second region with pattern_b.
>
> I can set the start of the forst sort with
>
> : /keyword_a
>
> in the script. But I dont know how to limit the range of the first
> sort so that only lines starting with keyword_a are sorted using
> pattern_a. Same goes for the second region...

Try something like

:0/^a/,/^\(a\)\@!/sort

It means loosely:

: - perform an ex command
0 - from before the beginning of the file
/^keyword_a/ - find a line beginning with 'keyword_a'
, - and operate until
/ - we find
^ - the beginning of a line
\(keyword_a\)\@! - where 'keyword_a' doesn't match
/sort - with the sort command

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

Indpendant position marks for scripts ?

Hi,

I want to process a text with script.
The text contains of two regions:
The first region contains of lines beginning with keyword_a
and the second one start with keyword_b.
I want to sort the first region using sort with pattern_a and
after that I want to sort the second region with pattern_b.

I can set the start of the forst sort with

: /keyword_a

in the script. But I dont know how to limit the range of the first
sort so that only lines starting with keyword_a are sorted using
pattern_a. Same goes for the second region...


Best regards and thank you very much for any help in advance!
Have a nice weekend!
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: Typing numbers

> [*] you can add more than one character, so if you wanted, you could
> get fancy with something like
>
> 40i-=<esc>
>
> to get a nice row of 80 characters like "-=-=-=-...=-=-=-=" but again you then
> have to do the math and divide down. Not grievous, but I can count the real-world
> times I've done that on one hand.

Or you can start taking down a receipt number without pushing i, as I
did last week. I typed 1011 before realising it hadn't appeared on the
screen. So then I pushed i and typed the whole 13-digit number, and when
I hit <Esc> I got 1011 copies of it, all running together as I had typed
no spaces or newlines or anything. Brilliant! There's 12 KB right there!

Was that too off-topic?

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: Typing numbers

On Fri, Jan 28, 2011 at 11:12:10PM EST, Ben Schmidt wrote:

> Hehe. Since we're sharing...If I were fixing 'rememberiing', I probably
> would have done:
>
> /ii<Enter>x
>
> No need to count, and no need to watch what I'm doing to know when to
> stop repeatedly pushing something either. I do this a lot. If I see an
> error on the screen, I just use / to quickly jump to it, or at least to
> something 'unique' in its near vicinity,

Yeah.. that's why I love sticking those pseudo-ellipses all over my
prose.

> and then fix it. Sometimes I don't type enough to get me straight
> there, and need an n or two, but that still tends to be quicker for me
> than moving around by repeating other movement keys. YMMV.

Hehe.. That's the problem about giving examples just to make a point:
contrary to f/F/t/T, that I really don't like all that much.. I use
/string a lot to move the cursor around the buffer.. Especially since
it's a standard mechanism with many other applications.. so now you
mention it.. that's more often than not what I would normally do..

Spoilsport.. :-)

cj

P.S. Not to mention that I would in most cases not even have noticed the
typo in the first place and spellchecking would have had to take care of
it 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: Typing numbers

On 01/28/2011 09:53 PM, Chris Jones wrote:
> On Fri, Jan 28, 2011 at 05:35:02PM EST, Tim Chase wrote:
>> This breaks when using t/T with ";" to repeat the motion as it just finds
>> the same one you just found. I have to break down and count for those :)
>
> Another reason why I don't use t/T (and don't care much for f/F either).

Eh, for the most part, the t/T/f/F work much like my brain on the
matter: "go forward to character X".. The only gotcha is
repeated attempt to use t/T with ";". With f/F it works fine.

> There's only so much can fit under my skull.

I can sympathize -- there are corners I rarely touch and see crop
occasionally to think "that would be really useful if I could
remember it at the times I need it" (the recent attempt was
learning the bash "!" expansions...poof, gone)

> 'i''s.. What would I really gain by counting 1, 2, 3.. it's the 3rd 'i'

Yeah, I'll often fall back do using f/F and then moving back one
character or reinserting whatever character I removed by
overshooting.

>> 80I-<esc>
>
> I vaguely remembered that there was a better way
[snip]
> One nice touch about the above sequence and makes it really elegant is
> the upper case 'I' because you can type it regardless of where the
> cursor is located on the current line: after you hit<Esc>, the cursor
> sits on the last of your inserted dashes, which means that you just need
> to type 'a' to switch to insert mode with the cursor on the first
> character following the last dash and 'Enter' to separate your line of
> dashes and the previous contents of the line and move down any ensuing
> text.

it works with i, I, gI, a, and A...on a blank line, it doesn't
make a difference as they all behave the same, inserting [count]
characters[*] at the defined location and leaving the cursor at
the end. With pre-existing content and leading whitespace, there
are subtle differences. However they all make sense depending on
what you want to do.

-tim

[*] you can add more than one character, so if you wanted, you
could get fancy with something like

40i-=<esc>

to get a nice row of 80 characters like "-=-=-=-...=-=-=-=" but
again you then have to do the math and divide down. Not
grievous, but I can count the real-world times I've done that on
one 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: Typing numbers

> There's only so much can fit under my skull.. and I prefer to stick with
> a limited subset of keyboard actions that may not be the quickest and
> most efficient for all occasions.. but that I can use without hesitation
> or incurring any overhead rememberiing. Namely that if the cursor is at
> the beginning of the line above and I want to get to the '..ii..' typo
> in 'rememberiing.', I find it considerably more effective when all is
> told to just hit 'w' till I get to the beginning of the word
> 'rememberiing'.. and either hit llll.. or hit 'e' to get to the end of
> the word and then 'hh' followed by 'x' to delete the last of the two
> 'i''s.. What would I really gain by counting 1, 2, 3.. it's the 3rd 'i'
> I want to remove.. or wait a minute.. is it the second..? Huh..
>
> Now I'm aware that I could also jump to the next sentence and work
> backward.. and there are probably other ways to get to that extra 'i' in
> fewer keystrokes than my clumsy approach, but all in all, I much prefer
> sticking to wwww.. or eeee.. and occasionally bbb.. etc. because it
> would take me longer to produce the 'find the third i' or 'jump to next
> sentence' key sequence than typing three or four (five or six..) 'w''s
> in succession.

Hehe. Since we're sharing...If I were fixing 'rememberiing', I probably
would have done:

/ii<Enter>x

No need to count, and no need to watch what I'm doing to know when to
stop repeatedly pushing something either. I do this a lot. If I see an
error on the screen, I just use / to quickly jump to it, or at least to
something 'unique' in its near vicinity, and then fix it. Sometimes I
don't type enough to get me straight there, and need an n or two, but
that still tends to be quicker for me than moving around by repeating
other movement keys. YMMV.

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: Typing numbers

On Fri, Jan 28, 2011 at 05:35:02PM EST, Tim Chase wrote:
>> I concur that prefixing Vim normal mode commands with a count, such as
>> '7dw' to delete the next seven words is ineffective.. Something like
>> 'dw....' where you delete the next word (dw) and repeat the last command
>> (.) a number of times is the way I normally do it because I don't have
>> to count the words before I even start deleting. While I hit the dot (.)
>> repeatedly, I can see what I'm deleting and I know when to stop.. And
>> I can always hit 'u' for undo to bring back the words I deleted one at
>> a time in the event I got carried away.
>
> This breaks when using t/T with ";" to repeat the motion as it just finds
> the same one you just found. I have to break down and count for those :)

Another reason why I don't use t/T (and don't care much for f/F either).

There's only so much can fit under my skull.. and I prefer to stick with
a limited subset of keyboard actions that may not be the quickest and
most efficient for all occasions.. but that I can use without hesitation
or incurring any overhead rememberiing. Namely that if the cursor is at
the beginning of the line above and I want to get to the '..ii..' typo
in 'rememberiing.', I find it considerably more effective when all is
told to just hit 'w' till I get to the beginning of the word
'rememberiing'.. and either hit llll.. or hit 'e' to get to the end of
the word and then 'hh' followed by 'x' to delete the last of the two
'i''s.. What would I really gain by counting 1, 2, 3.. it's the 3rd 'i'
I want to remove.. or wait a minute.. is it the second..? Huh..

Now I'm aware that I could also jump to the next sentence and work
backward.. and there are probably other ways to get to that extra 'i' in
fewer keystrokes than my clumsy approach, but all in all, I much prefer
sticking to wwww.. or eeee.. and occasionally bbb.. etc. because it
would take me longer to produce the 'find the third i' or 'jump to next
sentence' key sequence than typing three or four (five or six..) 'w''s
in succession.

And on a really bad day, after such a minor distraction.. I might even
need another little extra effort to remember why I moved the cursor
there in the first place.. Clever is not always better..

>> Come to think of it, the only pratical use I have for counts is when
>> I need something like a line of dashes:
>>
>> i -<Esc> x 80p
>>
>> IOW - i for insert mode, one dash,<Esc> back to normal mode, 'x' to
>> delete the dash and yank it to the unnamed register, and finally 80p to
>> create a line of eighty dashes..
>
> I just use
>
> 80I-<esc>
>
> to save the cut/yank :)

Thanks Tim, even better illustrates my point...

Incidentally, you have just put paid to maybe 2-3 years of frustration..
I vaguely remembered that there was a better way (probably saw it in vim
tips, or maybe s/o once mentioned it on this list) and never memorized
it properly.. Once in a while, I would try.. hm.. starts with typing 80-
in normal mode.. then what..?? and I was never able to bring it back.
I actually stopped trying because it so annoyed me. :-)

To make sure it'll stick *this* time, I'll practice it for the next few
days.. :-)

One nice touch about the above sequence and makes it really elegant is
the upper case 'I' because you can type it regardless of where the
cursor is located on the current line: after you hit <Esc>, the cursor
sits on the last of your inserted dashes, which means that you just need
to type 'a' to switch to insert mode with the cursor on the first
character following the last dash and 'Enter' to separate your line of
dashes and the previous contents of the line and move down any ensuing
text.

Thanks again for your comments.

cj


--
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: Scrolling screen lines, I knew, it's impossible.

On 29/01/11 1:44 PM, Bram Moolenaar wrote:
> Ben Schmidt wrote:
>
>> On 27/01/11 3:38 AM, oCameLo wrote:
>>> There's so many questions and feature requests about use mouse to
>>> scroll screen lines, but until now, it's still impossible.
>>
>> Bram, you're not opposed to this kind of feature, are you? So if I did
>> some work on it, it could be included in Vim at some stage, right?
>
> This is a change that has a high probablity of introducing new bugs.

True, though if coded carefully, these bugs should only appear when the
feature is turned on.

> There are also a few questions about how to allow the user to access
> this, with an option setting or with different scroll commands?
> Probably a setting, so that it can work with scrollbars.

I think it would probably be best to do this in stages:

1. Add new commands to scroll one screen line at a time. Test it out,
including by mapping the scrollwheel to those new commands in the X
GUIs. This shouldn't be too hard, as Vim can already display lines
starting part way through; it just usually doesn't. The experience
wouldn't be very smooth yet either, but screen-line scrolling would at
least be possible, and it would pave the way for something better.

2. Add an option to make scrolling work with screen lines. The meaning
of this option would be to affect all scrolling. To start with, though,
just make it change the meaning of the scroll wheel in X GUIs (already
implemented), and where easy, the clicks of the scroll bar arrows. It
might not affect Windows yet; it depends how the scrolling works there,
and I haven't looked in any detail.

3. Make other parts of Vim, such as moving line-to-line, vertical jumps,
and scrolling for scrolloff honour the new option, too, choosing window
positions that begin with partial lines. This would make the editing
experience pretty smooth.

4. Update the code for scrollbars more thoroughly, so that dragging the
bar can work with screen lines, too. Windows should definitely benefit
by this stage and the feature would basically be finished.

5. Pick the nits of little bugs that we can't foresee.

What do you think? Would this be an OK way to proceed?

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: Scrolling screen lines, I knew, it's impossible.

Ben Schmidt wrote:

> On 27/01/11 3:38 AM, oCameLo wrote:
> > There's so many questions and feature requests about use mouse to
> > scroll screen lines, but until now, it's still impossible.
>
> Bram, you're not opposed to this kind of feature, are you? So if I did
> some work on it, it could be included in Vim at some stage, right?

This is a change that has a high probablity of introducing new bugs.

There are also a few questions about how to allow the user to access
this, with an option setting or with different scroll commands?
Probably a setting, so that it can work with scrollbars.

--
If you feel lonely, try schizophrenia.

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
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: Remapping CTRL-I to

On Fri, Jan 28, 2011 at 03:14:36PM EST, Tim Chase wrote:
> On 01/28/2011 12:14 PM, Chris Jones wrote:

>> In my environment, this causes the<Alt+I> combo to send<Esc> to
>> Vim.. and it looks like it might work with no side effects -- I first
>> checked in insert mode that<Alt+I> did not do anything that I could
>> see and I don't remember ever using it for anything else (?).
>
> The only catch is that (depending on your encoding and other stellar
> alignments) some alt+letter combinations produce various accented
> & ASCII characters >128.

Sounds promising.. Straight US-ASCII boy that I am.. this shouldn't be
a problem. Matter of fact, the first thing I do to an XTerm is make sure
the 8th bit is disabled, so I can use Alt+. in the shell to retrieve the
last word of the previous command.

As in:

| $ mkdir foofoofoobarbarbar
| $ cd Alt+. # gives me: cd foofoofoobarbarbar etc.

I use this all the time.

> If you type those characters intentionally (which it sounds like you
> don't), it may interfere. Otherwise, they should be safe to use (as
> mentioned in a sibling reply, they're case-sensitive).

I usually enter such characters either via the compose key, level three
mappings accessed by pressign the Winkeys, or occasionally Vim digraphs.

Thanks,

cj

--
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: Starting out with VIM and C++

Thanks that helps out a lot.
--
View this message in context: http://vim.1045645.n5.nabble.com/Starting-out-with-VIM-and-C-tp3361804p3362244.html
Sent from the Vim - General mailing list archive at Nabble.com.

--
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: Typing numbers

> I concur that prefixing Vim normal mode commands with a count, such as
> '7dw' to delete the next seven words is ineffective.. Something like
> 'dw....' where you delete the next word (dw) and repeat the last command
> (.) a number of times is the way I normally do it because I don't have
> to count the words before I even start deleting. While I hit the dot (.)
> repeatedly, I can see what I'm deleting and I know when to stop.. And
> I can always hit 'u' for undo to bring back the words I deleted one at
> a time in the event I got carried away.

This breaks when using t/T with ";" to repeat the motion as it
just finds the same one you just found. I have to break down and
count for those :)

> Come to think of it, the only pratical use I have for counts is when
> I need something like a line of dashes:
>
> i -<Esc> x 80p
>
> IOW - i for insert mode, one dash,<Esc> back to normal mode, 'x' to
> delete the dash and yank it to the unnamed register, and finally 80p to
> create a line of eighty dashes..

I just use

80I-<esc>

to save the cut/yank :)

-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: Remapping CTRL-I to

On Fri, Jan 28, 2011 at 02:20:06PM EST, Ben Fritz wrote:
>
>
> On Jan 28, 12:14 pm, Chris Jones <cjns1...@gmail.com> wrote:
> >
> > Actually, while writing my reply, I tried a:
> >
> > | :inoremap <Esc>i <Esc>
> >
> > In my environment, this causes the <Alt+I> combo to send <Esc> to Vim..
> > and it looks like it might work with no side effects -- I first checked
> > in insert mode that <Alt+I> did not do anything that I could see and
> > I don't remember ever using it for anything else (?).
> >
>
> Alt keys do nothing special in Vim by default. If you're using GUI Vim
> you may need to read :help 'winaltkeys' but it sounds like you're
> sticking with the terminal.

Ah, yes.. that's probably what I had at the back of my mind re: using
the Alt modifier.

> You can probably map it directly:
>
> :inoremap <A-i> <Esc>
>
> or
>
> :inoremap <M-i> <Esc>

Well, you know what.. I've never been able to use the A- or M- syntax..
Tha's why I always specify <Esc> instead in my mappings. Time to revisit
this maybe..

> Note that Alt maps, unlike CTRL maps, are case-sensitive.

Interesting.. would mean that I can map Alt+<key> and Shift+Alt+<key> to
different things.. right?

Thanks,

cj

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