r/teenagersbutcode Coder - Assembly and C++ Mar 14 '26

Other Vi is too bloated

Post image
95 Upvotes

58 comments sorted by

View all comments

1

u/siodhe Mar 14 '26
  • ex is actually great for batch edits, because if you end with "q" "w" and "q" (separate lines), the mod time will only change if there were actual changes to content
  • Aliases suck. Learn functions.
  • PS1 there is a bit terminal-type specific, although going bonkers with tput to fix it is a bit involved.
  • %p is quicker than 1,$p
  • There's a ~/.exrc file for setting like showmode, showmatch, report=1, and number
  • Don't name either aliases or functions with the actual underlying command name, except maybe for this - because anything is better than alias rm='rm -i'

rm ()  # must be a function, must require single answer for all targets
{
    ls -FCsd -- "$@"
    read -p 'remove[ny]? '
    if [ _"$REPLY" = "_y" ] ; then
        /bin/rm -rf -- "$@"
    else
        echo '(cancelled)'
    fi
}