I want to map double space (" ") to output ". " in insert mode, but only for md, tex and txt filetypes. I tried pretty much everything, making md.vim file in ftplugin directory, making an autocmd, but neither works.
The last autocmd I tried was
autocmd FileType md inoremap <buffer> <space><space> .<space>
It does not work. What do I do?
Tried pretty much everything I could think of using autocmd, just like in this issue.
Is there any solution? Preferably using lua, like vim.keymap.set() function
You had to set markdown as a filetype, your vimscript was correct, here is an example of how to do it in lua:
local group = vim.api.nvim_create_augroup("markdown_autocommands", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
pattern = {"markdown", "txt"}, -- here you can add additional filetypes
callback = function(ev)
-- actual mapping
vim.api.nvim_buf_set_keymap(0, 'i', '<space><space>', '.<space>', { noremap = true, silent = true })
end,
group = group
})
:set filetype?
command.