-- A script for vim to map the word under the cursor with portingtools by pressing m, and all -- mapped expressions in the file with M local function map(name) return vim.fn.systemlist("portingtools map", name)[1] end vim.keymap.set("n", "m", function() local word = vim.fn.expand "" local mapped = map(word) local replaced = vim.fn.getline("."):gsub(word, mapped); vim.fn.setline(".", replaced) end) vim.keymap.set("n", "M", function() local nlines = 99 for i = 1, nlines do print(i .. "/" .. nlines) local line = vim.fn.getline(i) local mapped = line:gsub("field_%d+_[%a_]+", map):gsub("func_%d+_[%a_]+", map); vim.fn.setline(i, mapped) end end)