How To Save A File In Vim / Vi Without Root Permission With sudo

last updated in Categories , , , , , ,

This happens lot of times. I login as a normal user and start to edit httpd.conf or lighttpd.conf or named.conf in vim / vi text editor. However, I’m not able to save changes due to permission issue (all config files are owned by root). How do I save file without creating a temporary file (/tmp/httpd.conf) and then move the same (mv /tmp/httpd.conf /etc/httpd) as root using vim / vi itself?

How To Show or Hide Line Numbers In vi / vim Text Editor

last updated in Categories , , ,

How do I display vi / vim text editor line numbers while writing a shell script or c program? How can I turn on or off this feature on a Linux, Apple OS X/macOS, or Unix-like operating systems? How cah I make the vi text editor display or hide line numbers? How can I enable line numbers on vim startup by editing the ~/.vimrc config file?