vim: Add :<range>w <filename> command#41256
Conversation
1ef733b to
96d25d2
Compare
|
@AidanV Nice, thanks! When overwriting the current file in vim, the buffer retains it current contents. I think we should emulate this too (so the buffer is written, but marked as dirty). |
|
When writing to the current file we now retain the buffer contents and mark the buffer as conflicted. I also added a check to just save the file when we are selecting the entire buffer in order to match Vim. |
|
I don't think it should be marked conflicted? Just unsaved. What does vim do? |
|
Vim does not have the concept of conflicted as far as I am aware. Vim silently has different contents in the buffer and the file. I think that marking the buffer as conflicted provides a better UI since it informs the user that the file on disk changed without updating the buffer contents. Additionally, marking the buffer conflicted makes it more intuitive to get at the new file contents by clicking Another reason I think this is better is because writing a range of lines to its own file can be useful for Vim power users but can be very confusing for newcomers. Showing that it is conflicted improves the transparency of what is going on in a way that Vim cannot do by default. I should have included these reasons in the PR. I will do that next time. I will also happily change it if you still think it should be unsaved. Let me know your thoughts. |
|
Ok, conflicted makes sense. That said, on 8615b38, if I open README.md and type |
|
In the README.md file In Vim, |
|
Hmm, I'm sure when I tested this last night I was not seeing that; but trying again this morning it works as you say; sorry about that. |
Release Notes:
- Adds support for `:[range]w {file}`
- This writes the lines in the range to the specified
- Adds support for `:[range]w`
- This replaces the current file with the selected lines
Release Notes:
:[range]w {file}:[range]w