Is it possible to format DateTime in VIM under windows without leading zeroes on Month, Day, and Hour?
-
Does anyone know if there's a way to format the date generated by strftime in Vim (under MS Windows) such that Month, Day, and Hour are not padded to two digits with a leading zero? For example, the following commands in vimrc: nmap <F3> a<C-R>=strftime("%I:%M %p %m/%d/%Y ")<CR><Esc> imap <F3> <C-R>=strftime("%I:%M %p %m/%d/%Y ")<CR> will print 03:32 AM 07/09/2010 into the file, if it was actually July 9th. I'd like to know if there's a format string that will print 3:32 AM 7/9/2010 for vim instead. I know strftime is platform-specific, so I'm looking for a Windows-specific solution, without the use of external tools. I'd also appreciate comments to the effect that this is impossible with those constraints. Thanks.
-
Answer:
Replacing "%m" etc with "%#m" will remove the leading zeroes. So, your string redone as nmap <F3> a<C-R>=strftime("%#I:%M %p %#m/%#d/%Y ")<CR><Esc> gives me: 5:26 PM 1/8/2012 That works in Windows; I don't know if it's specific to Windows, or if there's another method on other platforms. Here's a page listing the format codes for Windows: http://msdn.microsoft.com/en-us/library/fe06s4ak%28VS.71%29.aspx
BC Armstrong at Quora Visit the source
Related Q & A:
- How to restore windows 7 without losing data?Best solution by Super User
- Is it possible to run Oracle Forms without applet?Best solution by Stack Overflow
- Is it possible to get a 6 pack in 1 month?Best solution by Yahoo! Answers
- What is the Command to Minimize Windows and Maximize Windows without using the mouse?Best solution by Yahoo! Answers
- What is the Command to Minimize Windows Maximize Windows switch Windows close Windows without using the mouse?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.