On Sun, Jun 20, 2010 at 4:25 PM, Tim Chase <vim@tim.thechases.com> wrote:
> On 06/20/2010 08:01 AM, yosi izaq wrote:
>>>
>>> For your particular use-case, I'd use vim's internal strftime() function:
>>>
>>> :nnoremap<f4> /^<c-r>=strftime('%d')<cr><bslash>><cr>
>>> :cnoremap<f4> <c-r>=strftime('%d')<cr>
>>
>> This works well. Can you please kindly explain why the 2nd line?
>
> You can see that it's just a subset of the previous command, the part that
> inserts the current day-of-the-month into the current search or the
> command-line.
I can see that. I don't understand what it's good for.
>
>>> You don't mention what single-digit dates look like in your file (whether
>>> they are left-justified, or padded with spaces or a leading zero).
>>
>> This is the matching pattern ^20$
>
> Today...the question revolves around what happens on the 1st through 9th?
> Do you need to search for "^01" or "^ 1" (with a leading space) or "^1"?
Sorry for not giving a clear explanation. for 1-9 I need to search for ^1 to ^9.
>>> So you
>>> might have to use "%e" (pad with spaces) instead of "%d" (pad with a
>>> zero)
>>> or strip the unwanted stuff:
Given that, I take it I need to change that %d in your maps to %e. right?
>>
>> %d works perfect
>
> Again, for the 10th-31st, it's not a problem. Just the 1st-9th where you
> need to make the search match what your file has.
>
>
>>> system("date | awk '{print $3}'")
>>>
>>> however, that returns the trailing newline, so you'd have to clean that
>>> out:
>>>
>>> substitute(system("date | awk '{print $3}'"), '\D', '', 'g')
>>>
>>>
>> I get: E486: Pattern not found: system
>
> These are expressions, and as such need to be entered with the "control+R
> followed by =" expression register:
>
> :help @=
got you. so now I tried:
let @/ = substitute(system("date | awk '{print $3}'"), '\D', '', 'g')
and n
it searches for plain 20. how can I make it search for ^20\>. What is
the string. concatenation operator?- And BTW, why doesn't VIM use
python as scripting language :-) ?
I need something like:
let @/ = '^' + substitute(system("date | awk '{print $3}'"), '\D', '',
'g') + '\>'
Thank you for all your help so far!
Yosi
--
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
No comments:
Post a Comment