You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
David-Apps edited this page May 6, 2023
·
7 revisions
Lines usually end with a newline character. So a text file usually ends with a newline character. Sometimes you might want to add or remove this newline character. You can use these functions to help you.
Add a trailing newline to the end of a buffer
# Add a trailing newline to the end of a buffer.
# usage: <at
# This function uses the label z.
function:at {
$X
kz
s/$/\n\n/f
'z+X
;g/^$/fd
}
Remove a trailing newline from the end of a buffer
# Remove a trailing newline from the end of a buffer.
# usage: <rt
function:rt {
db0
H-
ebvar+
$X
.v/^$/fr !echo -n '.
if(*) {
-d
}
}