At times I like to create a few blank lines at the right indent level, and then fill them all together later. Currently autoindent, even with cpoptions+=I enabled, deletes the just added indent after hitting <CR>. This way at any given point, only one blank line has the right indent level.
Example, after entering <CR> 3 times at the end of line containing let hello=world, there should be 3 indented lines below it. Then, as I move the cursor with <Up>/<Down>, it should move to the position where dots . are in the following code block.
if foo==bar
let hello=world
.
.
.
endif
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
I don't think there are more than a few users who would want to use this, adding "yet another option" is not really desired.
You can probably make it work like this:
:inoremap .
Hmm, github eats the angle brackets. Another try:
:inormap <CR> .<BS><CR>
@brammool I believe you got be wrong, the full stops . are only to indicate where cursor lands if one were to press <Up>/<Down> after entering 3 <CR>'s. Currently if I press <CR> thrice this is how it looks, and do <Up> the cursor moves to left column 0, and I need to hit tab again to get to reindent it.
if foo==bar
let hello=world
..
..
.
endif
@brammool This still doesn't fully work... Let's say after pressing <CR> three times, I hit <Up> arrow key, it deletes indent from the last line that was indented.
@vim-ml That doesn't work either. This worked: inoremap <CR> .<BS><CR><Left><Right>, quite interesting business...
—
You are receiving this because you were mentioned.
You can use any character instead of the dot, it just means that something was inserted and the won't remove the auto-indent. The auto-indent is removed because it looks like the user wants an empty line, and trailing white space is undesired in 99% of the cases.
—
You are receiving this because you were mentioned.
@brammool Thanks! As a side-note regarding predicting user intent, someone is already generating vim commands using OpenAI GPT3 model:
https://jameslu.substack.com/p/using-gpt-3-to-generate-vim-commands
—
You are receiving this because you were mentioned.
Depending on how you're creating the new line (ex. I mainly use 'o'), add a simple keymap
vim.keymap.set('n', 'o', 'o<Left><Right>', { noremap = true, silent = true })
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.![]()
I'd like to add that the autoindent is also removed if you use the up or down arrow key after creating the new line. So it's not just ‘move and it doesn't happen’ it's ‘move left or right and it doesn't happen’. That's is an insane amount of mental overhead when all I want to do is a normal mode operation on my new autoindented line.
I think that undoing an autoindent in the first place is a terrible feature. If you want to be picky with lines that consist of spaces, they should be removed when saving the file not when I'm trying to do something in normal mode on my autoindented line. 100% of the time that an autoindent is undone, I find myself indenting as my next operation. Surely that's a massive red flag.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you were mentioned.![]()