-- MAPPINGS for navigation
vis:map(vis.modes.INSERT, '<M-Backspace>', function()
	vis:feedkeys('<Escape>dbi')
end)
vis:map(vis.modes.INSERT, '<M-Left>', function()
	vis:feedkeys('<Escape>bi')
end)
vis:map(vis.modes.INSERT, '<M-Right>', function()
	vis:feedkeys('<Escape>ei')
end)
vis:map(vis.modes.INSERT, '<M-Up>', function()
	vis:feedkeys('<Escape><C-b>i')
end)
vis:map(vis.modes.INSERT, '<M-Down>', function()
	vis:feedkeys('<Escape><C-d>i')
end)
vis:map(vis.modes.NORMAL, '<M-Left>', function()
	vis:feedkeys('b')
end)
vis:map(vis.modes.NORMAL, '<M-Right>', function()
	vis:feedkeys('e')
end)
vis:map(vis.modes.NORMAL, '<M-Up>', function()
	vis:feedkeys('<C-b>')
end)
vis:map(vis.modes.NORMAL, '<M-Down>', function()
	vis:feedkeys('<C-d>')
end)

-- automatic commenting using #
vis:map(vis.modes.INSERT, '<M-#>', function()
	vis:feedkeys('<Escape>0^i#')
end)

-- automatic commenting using --
vis:map(vis.modes.INSERT, '<M-->', function()
	vis:feedkeys('<Escape>0^i--')
end)

-- automatic commenting using //
vis:map(vis.modes.INSERT, '<M-+>', function()
	vis:feedkeys('<Escape>0^i//')
end)

-- automatic commenting using /* */ for a single line
vis:map(vis.modes.NORMAL, '<M-+>', function()
	vis:feedkeys('0^i/* <Escape>A */<Escape>3h')
end)

-- automatic commenting using /* and */
vis:map(vis.modes.INSERT, '<C-^>', function()
	vis:feedkeys('<Escape>0O/*')
end)
vis:map(vis.modes.INSERT, '<C-_>', function()
	vis:feedkeys('<Escape>0o*/')
end)

vis:map(vis.modes.NORMAL, 'ü', function()
	local pos = vis.win.selection.pos
	vis:feedkeys('/<\\+\\+><Enter>')
	if not (pos == vis.win.selection.pos) then vis:feedkeys('v3lc') end
end)

vis:map(vis.modes.NORMAL, 'Ü', function()
	local pos = vis.win.selection.pos
	vis:feedkeys('?<\\+\\+><Enter>')
	if not (pos == vis.win.selection.pos) then vis:feedkeys('v3lc') end
end)

-- simple toggle for show-tabs/spaces
local swmode = 1
vis:map(vis.modes.NORMAL, '<C- >', function()
	swmode = (swmode + 1) % 2
	vis:command('set show-tabs '..swmode)
	vis:command('set show-spaces '..swmode)
end)

vis:map(vis.modes.INSERT, '<C-o>', function()
	vis:feedkeys('<Escape>O<Escape>jA')
end)
