diff options
| author | nsfisis <nsfisis@gmail.com> | 2022-03-21 20:53:40 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2022-03-21 20:53:58 +0900 |
| commit | 9477ec45222e9df6949a2c4894ba997d253c06ad (patch) | |
| tree | 4444d00a546c4f7210c7bfeaa5440893ace20d07 | |
| parent | 3a6c3f4d7f5f3b09b5d97cb36810f96676e81543 (diff) | |
| download | dotfiles-9477ec45222e9df6949a2c4894ba997d253c06ad.tar.gz dotfiles-9477ec45222e9df6949a2c4894ba997d253c06ad.tar.zst dotfiles-9477ec45222e9df6949a2c4894ba997d253c06ad.zip | |
neovim: simplify <C-a> in Insert Mode
| -rw-r--r-- | .config/nvim/init.lua | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 3134fba..67d3a33 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -326,22 +326,7 @@ vimrc.map('n', '`', '@@') vimrc.map('i', '<C-d>', '<Del>') -- Go elsewhere without deviding the undo history. -vimrc.map_expr('i', '<C-a>', function() - local repeat_ = F['repeat'] - local line = F.getline('.') - local cursor_col = F.col('.') - local space_idx = vim.regex('^\\S'):match_str(line) - - if cursor_col == space_idx + 1 then - return repeat_("\\<C-g>U\\<Left>", cursor_col - 1) - else - if cursor_col < space_idx then - return repeat_("\\<C-g>U\\<Right>", space_idx - cursor_col + 1) - else - return repeat_("\\<C-g>U\\<Left>", cursor_col - 1 - space_idx) - end - end -end) +vimrc.map('i', '<C-a>', "repeat('<C-g>U<Left>', col('.') - 1)", { expr = true }) vimrc.map('i', '<C-e>', "repeat('<C-g>U<Right>', col('$') - col('.'))", { expr = true }) vimrc.map('i', '<C-b>', '<C-g>U<Left>') vimrc.map('i', '<C-f>', '<C-g>U<Right>') |
