This tutorial uses pacman as the package management (uninstallation) program, but you can also use pikaur or yay instead, since the options discussed are the same for all these package managers.
Related: Automatic installation and update of AUR packages
A typical command to uninstall a program that will remove all package files:
sudo pacman -R PACKAGE
Indeed it will remove the specified package, but the configuration files of the package will remain, which will be renamed - the .pacsave extension has been added, and the dependencies that were installed for this package will remain.
To completely remove the program along with all its dependencies and without saving the configuration files, use a command like this:
sudo pacman -Rscun PACKAGE
This command uses the following options:
-c, --cascade
Remove all target packages, as well as all packages that depend on one or more target packages. This operation is recursive and must be used with caution as it can remove many potentially needed packages.
-n, --nosave
Instructs pacman to ignore backup configuration files. Usually, when a package is removed from the system, the database checks whether the configuration file should be renamed (the .pacsave extension is appended to it). When using this option, this does not happen - the configuration files are completely deleted.
-s, --recursive
Removes every specified target, including all its dependencies, provided that: (A) they are not required by other packages; and (B) they were not explicitly installed by the user. This operation is recursive and similar to the reverse --sync operation, and it helps to keep the system clean without orphans. If you want to skip condition (B), write the option twice.
-u, --unneeded
Removes targets that are not required by other packages. This is mostly useful when removing a group without using the -c option to avoid breaking any dependencies.