better space backspacing and add a paragraph wrapping keybinding

This commit is contained in:
Felix Van der Jeugt 2019-06-04 21:40:57 +02:00
parent 9b0bff728d
commit 756494b150
No known key found for this signature in database
GPG Key ID: 58B209295023754D
1 changed files with 24 additions and 6 deletions

View File

@ -66,16 +66,26 @@ vis:map(vis.modes.NORMAL, ";b", function()
end)
vis:map(vis.modes.INSERT, '<Backspace>', function()
local found_tab = true
local tabwidth = 4
local single_selection = false
for selection in vis.win:selections_iterator() do
local pos = selection.pos
if not pos or pos < tabwidth or vis.win.file:content(pos - tabwidth, tabwidth) ~= string.rep(' ', tabwidth) then
found_tab = false
if single_selection then
single_selection = false
break
end
end
vis:feedkeys(string.rep('<vis-delete-char-prev>', found_tab and tabwidth or 1))
single_selection = true
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)
vis:map(vis.modes.NORMAL, ";s", function()
@ -85,3 +95,11 @@ end)
vis:map(vis.modes.NORMAL, ";p", function()
vis:command("<xclip -o")
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)