local userregs = require("vim.userregs") -- Get format from g:timestamp_register_format or use fallback local function get_timestamp_format() return vim.g.timestamp_register_format or "%Y-%m-%d %H:%M:%S" end local function generate_timestamp() local ok, result = pcall(os.date, get_timestamp_format()) if not ok then vim.notify("[userregs] Invalid timestamp format", vim.log.levels.WARN) return os.date("%Y-%m-%d %H:%M:%S") end return result end userregs.register_handler('\20', { put = function() return generate_timestamp() end, yank = nil, -- read-only })