mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 02:34:59 -07:00
feat(defaults): unimpaired empty line below/above cursor #30984
This commit is contained in:
parent
a27419f3fc
commit
079e5f4f9b
@ -1907,6 +1907,16 @@ These commands are used to start inserting text. You can end insert mode with
|
||||
<Esc>. See |mode-ins-repl| for the other special characters in Insert mode.
|
||||
The effect of [count] takes place after Insert mode is exited.
|
||||
|
||||
The following commands insert text, but stay in normal mode:
|
||||
|
||||
*]<Space>*
|
||||
]<Space> Insert an empty line below the cursor without leaving
|
||||
Normal mode, repeat [count] times.
|
||||
|
||||
*[<Space>*
|
||||
[<Space> Insert an empty line above the cursor without leaving
|
||||
Normal mode, repeat [count] times.
|
||||
|
||||
When 'autoindent' is on, the indent for a new line is obtained from the
|
||||
previous line. When 'smartindent' or 'cindent' is on, the indent for a line
|
||||
is automatically adjusted for C programs.
|
||||
|
@ -178,6 +178,7 @@ DEFAULTS
|
||||
• |[t|, |]t|, |[T|, |]T|, |[CTRL-T|, |]CTRL-T| navigate through the |tag-matchlist|
|
||||
• |[a|, |]a|, |[A|, |]A| navigate through the |argument-list|
|
||||
• |[b|, |]b|, |[B|, |]B| navigate through the |buffer-list|
|
||||
• |[<Space>|, |]<Space>| add an empty line above and below the cursor
|
||||
|
||||
• Snippet:
|
||||
• `<Tab>` in Insert and Select mode maps to `vim.snippet.jump({ direction = 1 })`
|
||||
|
@ -163,6 +163,7 @@ of these in your config by simply removing the mapping, e.g. ":unmap Y".
|
||||
- |[t|, |]t|, |[T|, |]T|, |[CTRL-T|, |]CTRL-T|
|
||||
- |[a|, |]a|, |[A|, |]A|
|
||||
- |[b|, |]b|, |[B|, |]B|
|
||||
- |[<Space>|, |]<Space>|
|
||||
- Nvim LSP client defaults |lsp-defaults|
|
||||
- K |K-lsp-default|
|
||||
|
||||
|
@ -363,6 +363,19 @@ do
|
||||
cmd({ cmd = 'blast' })
|
||||
end
|
||||
end, { desc = ':blast' })
|
||||
|
||||
-- Add empty lines
|
||||
vim.keymap.set('n', '[<Space>', function()
|
||||
local repeated = vim.fn['repeat']({ '' }, vim.v.count1)
|
||||
local linenr = vim.api.nvim_win_get_cursor(0)[1]
|
||||
vim.api.nvim_buf_set_lines(0, linenr - 1, linenr - 1, true, repeated)
|
||||
end, { desc = 'Add empty line above cursor' })
|
||||
|
||||
vim.keymap.set('n', ']<Space>', function()
|
||||
local repeated = vim.fn['repeat']({ '' }, vim.v.count1)
|
||||
local linenr = vim.api.nvim_win_get_cursor(0)[1]
|
||||
vim.api.nvim_buf_set_lines(0, linenr, linenr, true, repeated)
|
||||
end, { desc = 'Add empty line below cursor' })
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -152,6 +152,54 @@ describe('default', function()
|
||||
]],
|
||||
})
|
||||
end)
|
||||
|
||||
describe('[<Space>', function()
|
||||
it('adds an empty line above the current line', function()
|
||||
n.clear({ args_rm = { '--cmd' } })
|
||||
n.insert([[first line]])
|
||||
n.feed('[<Space>')
|
||||
n.expect([[
|
||||
|
||||
first line]])
|
||||
end)
|
||||
|
||||
it('works with a count', function()
|
||||
n.clear({ args_rm = { '--cmd' } })
|
||||
n.insert([[first line]])
|
||||
n.feed('5[<Space>')
|
||||
n.expect([[
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
first line]])
|
||||
end)
|
||||
end)
|
||||
|
||||
describe(']<Space>', function()
|
||||
it('adds an empty line below the current line', function()
|
||||
n.clear({ args_rm = { '--cmd' } })
|
||||
n.insert([[first line]])
|
||||
n.feed(']<Space>')
|
||||
n.expect([[
|
||||
first line
|
||||
]])
|
||||
end)
|
||||
|
||||
it('works with a count', function()
|
||||
n.clear({ args_rm = { '--cmd' } })
|
||||
n.insert([[first line]])
|
||||
n.feed('5]<Space>')
|
||||
n.expect([[
|
||||
first line
|
||||
|
||||
|
||||
|
||||
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user