vim-easyescape icon indicating copy to clipboard operation
vim-easyescape copied to clipboard

Indenting in Python files

Open kuator opened this issue 6 years ago • 6 comments

After pressing kj cursor goes to the beginning of line another And that's normal behavior But after I installed plugin it doesn't do this gif

kuator avatar Feb 01 '19 19:02 kuator

This seems to be a "bug" in vim. If you type x<BS><Esc> on an empty line you still get the same behavior. Not sure I should work around it in the plugin or fix it in vim.

zhou13 avatar Feb 02 '19 00:02 zhou13

Please work around it.

:h autoindent

Copy indent from current line when starting a new line (typing <CR> in Insert mode or when using the "o" or "O" command). If you do not type anything on the new line except <BS> or CTRL-D and then type <Esc>, CTRL-O or <CR>, the indent is deleted again.

Please preserve this behavior.

vim-easyescape-plus seems to have a workaround and a nice feature keeping the buf status as unmodified if nothing modified. But unfortunately it doesn't map jk kj simultaneously.

fatjing avatar Nov 08 '20 08:11 fatjing

Thank you for the infomation. However, I am not sure how to preserve this behavior. I take a look at vim-easyescape-plus. It will insert a c-w if current only contains <space>. This might be less annoying than the current solution, but it is still not the ideal behavior of autoindent.

zhou13 avatar Nov 10 '20 20:11 zhou13

I push my workaround. Let me know if it is better.

zhou13 avatar Nov 10 '20 20:11 zhou13

It is better now. Thank you. How about reverting the modified buffer status? Entering insert mode and doing nothing, a true <Esc> brings back to normal mode with everything intact, while this plugin leaves the buffer modified.

fatjing avatar Nov 12 '20 14:11 fatjing

The workaround works great for me! But, it also overwrites the unnamed buffer with whatever whitespace got deleted. Would it be easy to send the whitespace to "_ to avoid that?

Thanks!

Edit: looks like you got that too, thank you!

aselker avatar Nov 17 '20 02:11 aselker

One lingering problem: after deleting the whitespace, the "." command repeats the delete. Is it possible to run a command without overwriting the . buffer?

aselker avatar Oct 14 '22 22:10 aselker

I am not sure how to do that since according to the definition of ".", it repeats the last change. This might be possible with https://github.com/tpope/vim-repeat, but I am not really familiar with it.

zhou13 avatar Oct 19 '22 02:10 zhou13

Since the original question is partially solved, I will close this issue. Let me know if you have better ideas.

zhou13 avatar Oct 19 '22 02:10 zhou13