diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua index 29b94e7..d49daa4 100644 --- a/.config/nvim/lua/keymaps.lua +++ b/.config/nvim/lua/keymaps.lua @@ -33,12 +33,13 @@ map('n', '', '') map('v', 'y', '"+y') map('n', 'p', '"+p') -map('n', '', -- toggle between beginning of line and beginning of text +-- toggle between beginning of line and beginning of text +map({ 'n', 'i', 'v' }, '', function() local row, col = unpack(vim.api.nvim_win_get_cursor(0)) if (col == 0) then - -- TODO: figure out which function that calls - vim.api.nvim_feedkeys('^', 'n', false) + local col_new = vim.api.nvim_get_current_line():match('^%s*'):len() + vim.api.nvim_win_set_cursor(0, { row, col_new }) else vim.api.nvim_win_set_cursor(0, { row, 0 }) end