Timeline for Paste in normal mode ignores autoindent
Current License: CC BY-SA 4.0
16 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 25, 2019 at 8:10 | answer | added | Biggybi | timeline score: 0 | |
Jul 24, 2018 at 18:29 | vote | accept | tga | ||
S Jul 24, 2018 at 17:30 | history | suggested | Hotschke | CC BY-SA 4.0 |
Improve English, clarify question and update tags.
|
Jul 24, 2018 at 17:20 | answer | added | Hotschke | timeline score: 1 | |
Jul 24, 2018 at 17:08 | comment | added | Christian Brabandt |
I don't understand what problem you are trying to solve. But why leave insertmode for pasting? You can use o<CTRL-R>0 to paste the last yanked text and not mess with the indent. See also the various options at :h i_CTRL-R
|
|
Jul 24, 2018 at 16:27 | answer | added | Hotschke | timeline score: 0 | |
Jul 24, 2018 at 15:56 | review | Suggested edits | |||
S Jul 24, 2018 at 17:30 | |||||
Jul 24, 2018 at 15:18 | answer | added | Hotschke | timeline score: 1 | |
Jul 23, 2018 at 15:44 | comment | added | Shahbaz |
Smashing any key with vim is always a bad experience ;) If I accidentally lose the tab when I want to paste (as in the situation in the example), instead of going in insert mode, fix the indent, escape and paste, I do this: p==A . This will paste what I want to paste, fix the indentation of the current line, and then go to insert mode at the end of the line.
|
|
Jul 23, 2018 at 14:33 | comment | added | tga |
i personally wrote a function to delete all trailing spaces on file save, but losing indent and have to smash tab all the way is straight up bad experience haha
|
|
Jul 23, 2018 at 13:57 | comment | added | Shahbaz |
Personally, I've come to appreciate this behavior, although sometimes annoying. I hate whitespace after end-of-line (including empty lines that just have whitespace), and this behavior greatly helps me avoid that. With your remapping, if you press <enter><enter> to create an empty line between different pieces of your code, the empty line is gonna have the indent whitespace. In git, if you set core.whitespace to blank-at-eol for example, you're gonna have a bad time.
|
|
Jul 23, 2018 at 13:52 | comment | added | Shahbaz |
I'm surprised you are saying that going back to insert mode after <esc> puts the indent back. For me, after <esc> the indent is gone, and pressing i puts you at the beginning of the line.
|
|
Jul 21, 2018 at 3:10 | comment | added | tga |
@Shahbaz i did a inoremap <return> <return>yo<backspace><backspace> and it works as expected! i'm not sure if this is exactly what you meant but it worked. but still if i press <esc> the cursor goes back a full tab, but if i enter insert mode again it went back to the correct indent, and the indent seems actually there (can be selected), i don't understand why in normal mode it's ignoring the last indent..
|
|
Jul 20, 2018 at 17:28 | comment | added | Shahbaz | I have noticed this as well. The autoindent you get when you hit enter is not really there (which is also why it gets removed as you hit enter again), as in no actual character is inserted. When you hit escape, that fake indent is also removed, I presume because otherwise vim would be inserting whitespace after end of line (which is a no no). What you see is a side effect of escape removing the indent before you paste. I personally always do a quick "some key followed by backspace" to "consolidate" the indent, then paste. | |
Jul 20, 2018 at 17:15 | history | edited | tga | CC BY-SA 4.0 |
added 92 characters in body
|
Jul 20, 2018 at 16:59 | history | asked | tga | CC BY-SA 4.0 |