Vim Tips Wiki
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Vim Tips Wiki
1,649
pages
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
Editing
Enhance the calendar script with special dates
Back to page
Edit
Edit source
View history
Talk (0)
Edit Page
Enhance the calendar script with special dates
We recommend that you
log in
before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your
Watchlist
.
Creating an account
is quick and free.
The edit appears to have already been undone.
Anti-spam check. Do
not
fill this in!
{{review}} {{TipImported |id=408 |previous=407 |next=409 |created=January 19, 2003 |complexity=basic |author=Suresh Govindachar |version=6.0 |rating=11/5 |category1= |category2= }} To enhance Calendar {{script|id=52}} with display of special dates: Step 1. Create a file called "holidays" in the directory assigned to g:calendar_diary (default value for g:calendar_diary is ~/diary). This file will contain the special dates. Essence of contents of the holidays file is the special dates encoded as (10000+(month*100)+day). Example contents of file g:calendar_diary/holidays <pre> List of holidays: ^(10000 + ((month * 100)+day)) Encoded Sign Color Description Date 10101 n blue Jan 01 (Wed) - New Year's Day 10217 p blue Feb 17 (Mon) - President's Day 10214 v red Feb 14 (Fri) - Valentine's Day 10414 s green Apr 14 (Mon) - Spring Break 10526 m blue May 26 (Mon) - Memorial Day 10703 i gold 10704 i gold Jul 3&4 (Thu & Fri)- Independence Day + 1 day 10901 l blue Sep 01 (Mon) - Labor Day 11127 t blue Nov 27&28(Thu & Fri)- Thanksgiving Day + 1 day 11128 t blue 11225 c silver Dec 25&26(Thu & Fri)- Christmas Day + 1 day 11226 c silver Dec 25&26(Thu & Fri)- Christmas Day + 1 day </pre> Step 2. Add the following to your vimrc file: <pre> let calendar_sign = 'MyGetSpecialDay' function! MyGetSpecialDay(day, month, year) let l:m100d = 10000 + (a:month * 100 ) + a:day let l:holidays = expand(g:calendar_diary) . "/holidays" exe "split " . l:holidays let l:found = search(l:m100d) if l:found let l:found = 'h' endif quit return l:found endfunction </pre> Note: The preceding constitutes basic support for display of special dates. With this basic support, all special dates are shown with the same sign (viz. +) and the same highlight color. An enhancement would be to pick up the sign and the highlight color from the holidays file. (Also, I suspect management of buffer for the holidays file can be speeded up, perhaps by opening it only once, keeping it in the background and searching with warp-around flag ('w').) ==Comments==
Summary:
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Navigation
(
view source
)
Template:Review
(
view source
)
Template:Script
(
view source
)
Template:TipImported
(
view source
)
Follow on IG
TikTok
Join Fan Lab