... and look towards the lower-right-corner of the screen. -ArunMessage 1 of 7 , May 2, 2005View SourceIf the selection is within a line and if you just want to see the len:
and look towards the lower-right-corner of the screen.
On Mon, 2 May 2005, Edward WIJAYA wrote:
> Suppose I want to measure then length of the
> string highlighted under visual mode.
> Is there a way to do it?
> Edward WIJAYA
... I think visualmode() would work here ... It doesn t matter if you ve crossed into normal mode, since it returns what the mode was last time visual mode wasMessage 1 of 7 , May 10, 2005View Source
>-----Original Message-----I think visualmode() would work here ... It doesn't matter if you've
>From: Eric Arnold [mailto:eric_p_arnold@...]
>Sent: Sunday, May 01, 2005 9:45 PM
>To: jamessan@...; vim@...
>Subject: Re: Using "strlen" under Visual Mode[answer + question]
>--- jamessan@... wrote:
>> On Mon, May 02, 2005 at 06:49:19AM +0800, Edward WIJAYA wrote:
>> > Suppose I want to measure then length of the string highlighted
>> > under visual mode.
>> > Is there a way to do it?
>> You could yank the text into a register and then call strlen on the
>> buffer. For example:
>> <select visual range>
>> :echo strlen(@a)
>If you want to restore the selection area, try:
>or V or which-ever. I tried making a function to do it automatically,
> function! Vislen()
> let modetype = mode()
> let do = 'normal "by`<' . modetype . '`>'
> echo do
> exe do
> echo modetype . ": strlen(" . @b . ")=" . strlen(@b)
> map ,t :call Vislen()<CR>
>but the "mode()" call returns "n" normal mode when I call the
>,t macro from a visual selection. The help says:
> This is useful in the 'statusline'
>option. In most other
> places it always returns "c" or "n".
>Sadly, the help for "mode()" doesn't refer you to what
>actually works, getregtype(). It does mean that you can't
>find out the mode without yanking into a register, as far as I
crossed into normal mode, since it returns what the mode was last time
visual mode was entered.