I sometimes have to cut a line (d
) and paste in in the middle of another line. I'd like to remove the whitespaces that vim has copied (i.e. trim/strip the content). How can I do that in vim?
A common use case is that.
value := getValue()
if value == "test" {
// Do something with value
In go, it is idiomatic to use if value := getValue(); value == "test"
if value is only used within the if. However, sometimes I write the variable declaration outside of the if because I either used the variable after the if (and later moved that code inside the if), or because I simply forgot it. So, I'd like to cut the line value := getValue()
and paste it after if
. If I press p
or P
, it is inserted after (or before) the current line. Can I somehow insert that line onto the current line and remove the starting/trailing whitespaces (tabs, new lines, and )? I often have to do that in Latex documents, too.