I inserted the 'datetime' snippet from vim-snippets/all.snippet right at the beginning of my document.
The problem is that the time keeps on updating whenever I scroll, as if vim is redrawing the screen and executing the snippet at the same time. What this leads to is, I end up with the time at which the file is closed. Please help me fix the issue.
snippet datetime "YYYY-MM-DD hh:mm" w
`!v strftime("Date: %d %B, %Y | Time: %X")`
endsnippet
UPDATE 2:
base_file
snippet base_file "Competitive Programming Template File" b
/*
** Date: `!v strftime("%A, %d %B, %Y")`
** Time: `!v strftime("%X")`
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define sz(x) (int)x.size()
#define rep(a, b, i) for (int i = a; i < b; i++)
#define repi(a, b, i) for (int i = a; i > b; i--)
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define __ \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
#define CPU \
cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int MOD = 1e9 + 7;
const ll inf = 1e18 + 5;
const ld pi = 3.141592653589793;
const int maxn = 1e5 + 5;
int32_t main() {
__;
int t;
cin >> t;
while (t--) {
${1}
}
return 0;
}
endsnippet
outputs:
:autocmd CursorHold and :autocmd SafeState are empty
:autocmd CursorMoved
--- Autocommands ---
matchparen CursorMoved
* call s:Highlight_Matching_Pair()
ycmcompletemecursormove CursorMoved
* call s:OnCursorMovedNormalMode()
UltiSnips CursorMoved
* call UltiSnips#CursorMoved()
I randomly tried entering this command: :call UltiSnips#CursorMoved()
The same thing happened, i.e. the time updated. I think there is some problem with this command.
datetime
hit your trigger key, current date and time string appeared, then you scrolled away and the time continuously advances while you're moving? That's wild. Never heard of such a thing. Interference from another plugin? Do you use, errr, YouCompleteMe? Try removing all other plugins except UltiSnips and see if the problem still occurs.expand
trigger.