vim-Insert Formatting time

Source: Internet
Author: User
Tags python script

Recently has been engaged in the configuration of VIMRC. One of the things that I want to do is to implement the code quick Comment function. And one of the key points in this feature is that I'm going to get the system current time and then insert it into my comment
Inside. I know VIMRC supports shell commands, both using: Read!<...>, and the shell command inside the angle brackets. So, at first I was directly using the date-r to achieve. Specific as follows

: Read! Date -R


However, you will find that this time the display style is as follows:

 A  - : From: + 0800


This style looks a little strange, especially after adding a 0800. The time style I want is 15-10-10. This seems to be very simple, as long as we put the date command inside the angle brackets, add a time > Display format is not OK. Then I made the following changes

: Read! Date +%y-%m-%d


However, when I change this, the result is inexplicable.
Prompt as follows

Date: Invalid option--'date--help' for more information.


A lot of commands were tried in the middle, and the results were the same. has been tangled up for two or three days, the middle is also a variety of online Baidu, I have made a variety of attempts, such as, with the shell command double quotation marks, and even the life
To write to the Python script and execute it in VIMRC (of course, this is definitely a blind attempt, because I don't know if VIMRC is supporting the script at all)
Finally, suddenly a flash of light, is to think of the percent of this symbol in the VIM command line role. It is itself in the VIM command line, which represents the entire text. At that time thought, could it be because of this. Then, you add a
An escape operation. As follows

: Read! Date +\%y-\%m-\%d


Now the results are as follows

---


This has fulfilled my original request.
So, a lot of times, the problem must be able to solve, whether we find the answer through the Internet, or we try. If we want to solve a problem, and we have been thinking about how to > solve the problem, there is a time when we have a flash, we will find the answer we want

vim-Insert Formatting time

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.