Add :PreProcIfWrap command and C/C++ mappings
Quickly wrap a line or range in `#if 0`/`#endif` to quickly disable compilation of sections of code.
This commit is contained in:
@@ -126,3 +126,13 @@ vim.api.nvim_create_user_command('Rg', function(opts)
|
||||
end
|
||||
require('telescope.builtin').grep_string(grep_opts)
|
||||
end, { bang = true, nargs = '*' })
|
||||
|
||||
vim.api.nvim_create_user_command('PreProcIfWrap', function(opts)
|
||||
local buffer = vim.api.nvim_get_current_buf()
|
||||
vim.api.nvim_buf_set_lines(
|
||||
buffer, opts.line2, opts.line2, true, { '#endif' })
|
||||
vim.api.nvim_buf_set_lines(
|
||||
buffer, opts.line1 - 1, opts.line1 - 1, true, { '#if 0' })
|
||||
local window = vim.api.nvim_get_current_win()
|
||||
vim.api.nvim_win_set_cursor(window, { opts.line1, 5 })
|
||||
end, { range = true })
|
||||
|
||||
Reference in New Issue
Block a user