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.
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"?
So you
might have to use "%e" (pad with spaces) instead of "%d" (pad with a zero)
or strip the unwanted stuff:
%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 @=
Hope this helps,
-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