better space backspacing and add a paragraph wrapping keybinding
This commit is contained in:
parent
9b0bff728d
commit
756494b150
@ -66,16 +66,26 @@ vis:map(vis.modes.NORMAL, ";b", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
vis:map(vis.modes.INSERT, '<Backspace>', function()
|
vis:map(vis.modes.INSERT, '<Backspace>', function()
|
||||||
local found_tab = true
|
|
||||||
local tabwidth = 4
|
local tabwidth = 4
|
||||||
|
local single_selection = false
|
||||||
for selection in vis.win:selections_iterator() do
|
for selection in vis.win:selections_iterator() do
|
||||||
local pos = selection.pos
|
if single_selection then
|
||||||
if not pos or pos < tabwidth or vis.win.file:content(pos - tabwidth, tabwidth) ~= string.rep(' ', tabwidth) then
|
single_selection = false
|
||||||
found_tab = false
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
single_selection = true
|
||||||
vis:feedkeys(string.rep('<vis-delete-char-prev>', found_tab and tabwidth or 1))
|
end
|
||||||
|
|
||||||
|
local to_stop = (vis.win.selection.col - 1) % tabwidth
|
||||||
|
if to_stop == 0 then
|
||||||
|
to_stop = tabwidth
|
||||||
|
end
|
||||||
|
|
||||||
|
if single_selection and to_stop > 1 and vis.win.file:content(vis.win.selection.pos - to_stop, to_stop) == string.rep(' ', to_stop) then
|
||||||
|
vis:feedkeys(string.rep('<vis-delete-char-prev>', to_stop))
|
||||||
|
else
|
||||||
|
vis:feedkeys('<vis-delete-char-prev>')
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
vis:map(vis.modes.NORMAL, ";s", function()
|
vis:map(vis.modes.NORMAL, ";s", function()
|
||||||
@ -85,3 +95,11 @@ end)
|
|||||||
vis:map(vis.modes.NORMAL, ";p", function()
|
vis:map(vis.modes.NORMAL, ";p", function()
|
||||||
vis:command("<xclip -o")
|
vis:command("<xclip -o")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
vis:map(vis.modes.VISUAL, ';a', function()
|
||||||
|
if vis.count then
|
||||||
|
vis:command(string.format(':|par %d', vis.count))
|
||||||
|
else
|
||||||
|
vis:command(':|par')
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user