New answers tagged


Using lua api (nvim) we can do: line, col = unpack(vim.api.nvim_win_get_cursor(0)) vim.cmd [[ normal 4X]] vim.cmd [[ normal u]] vim.api.nvim_win_set_cursor({0}, {line , col}) The first line saves line and column, the second line erases 4 chars, the third one gets back one action and the last one restores the line and cursor positions. Your question helped ...


There is no straightforward way to tell vim to land the cursor at a particular place in the cmdline during a map, but there are a number of workarounds. Direct positioning autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt<c-r>=setcmdpos(getcmdpos()-31)[1]<cr> You can use setcmdpos() to ...


Normally prefer :h ftplugin over autocmd FileType. If still want autocmd, at least, put it into augroup. Use :h map-<buffer> to define a local mapping. Otherwise it will affect all other buffers/windows too. Typing foo[cursor]bar is as simple as bar<C-B>foo.

Top 50 recent answers are included