7

:%s,\v(\d+)/(\d+)/(\d+),\3/\1/\2,g s is the substitution command, the % before it means that all lines of the file will be considered. , is the separator. It is common to choose / as the separator, but since there are slashes in the pattern and replacement, it is useful to choose another separator, so as to avoid escaping. \v enables very magic mode, so ...


7

There is the reltime() function to get relative times, and reltimestr() to display that as the number of seconds: :let start = reltime() :echo reltime(start) [65, 11796] :echo reltimestr(reltime(start)) 71.267801 So in your case, you would do something like: function MaFunction() let start = reltime() call Function1() echom printf('Duration = ...


5

You can use timer_start() to set "timers" to run a function every n milliseconds. For example: fun! s:set_bg(timer_id) let &background = (strftime('%H') < 12 ? 'light' : 'dark') endfun call timer_start(1000 * 60, function('s:set_bg'), {'repeat': -1}) call s:set_bg(0) " Run on startup This will run s:set_bg() every 1 minute (60,000 milliseconds),...


4

Here's a simple, somewhat dumb solution, that doesn't require any plug-ins or anything. Just add this snippet to your vimrc: iabbrev <expr> debsig \ ' -- Alexis Wilke <alexis@example.com> ' \ . strftime('%a, %d %b %Y %H:%M:%S %z') This creates an "abbreviation", which you can later invoke by typing debsig and then pressing return or ...


3

As a workaround one can instead target the common FocusLost / FocusGained events. function DynamicColorThemeSwitch() if strftime("%H") < 18 set background=light colorscheme zellner else set background=dark colorscheme nightfly endif endfunction autocmd FocusLost,FocusGained * call DynamicColorThemeSwitch() call ...


2

You can also use snippet plugin such as ultisnips to achieve this. Just write a short snippet for it. For how to configure ultisnips, see this post. You need to create a file named debchangelog.snippets in the custom snippet directory and add the following snippet into it: snippet debsig "debian change log signature" w -- Alexis Wilke <alexis@example....


1

I have this command in my vimrc which you can tweak to get your exact text; then I do :Changed and it updates all the timestamps in the current file: command Changed keeppatterns %substitute/Last [cC]hanged\?:\zs.*/\=strftime(" %Y %b %d")/e


1

You can try using strptime function, if available, to convert both dates to unix time, substract and get number of seconds. Unfortunately on my win box this func is not available. Something like this, NOT TESTED: let u_time1 = strptime("%c", "24/03/2020 07:31:22") let u_time2 = strptime("%c", "24/03/2020 07:31:28") echo "Duration = " . (u_time2 - u_time1)...


1

If you frequently find yourself wanting to insert the current date into command-line commands you could set up a mapping like this using something similar to what's in the existing answer: :cnoremap YMD <C-R>=strftime("%Y-%m-%d")<CR> Your use case then would be to enter :w myFile-YMD Which, right after you hit D, will be converted to :w ...


1

There are two ways to do this. The first one is interactive, using CTRL-R = in the Ex command-line to enter an expression and evaluate it. Start by typing the command as usual: :w myFile-, then press CTRL-R, =. You'll now have a = prompt where you can enter an expression. Enter strftime("%F") and press "Enter", Vim will evaluate that to 2020-03-27 (...


1

In my plugin library, I define the following to help running a function n times in order to have an estimation of the time it takes to execute It's meant to be used this way echo lh#time#bench_n(10000, function('Function1'), the, list, of, parameters)[1] / 10000 lh#time#bench_n() returns a list of two elements: the 10000 results of the 10000 function ...


Only top voted, non community-wiki answers of a minimum length are eligible