The command I use most in Linux is without doubt less. I never open text files in a text editor if I just want to read the file as it is a lot easier to enter the command:
less filename
It can also be fed through a pipe. For example, in the directory /usr/bin the command ls -l will likely result pages of output scrolling through the window. You can use less to see less files:
ls -l | less
Less has several useful keyboard shortcuts. The one I use most is b that by default scrolls output backward one page. Pressing space scrolls one page forward.
It took me some years, before I accidentally pressed the button v. It opened the text file in the editor VIM, ready to be edited at the line I had just been looking at. If I had read the man page for less, I certainly would have found this feature earlier.
If VIM (or other VI-like editors) is not your favourite editor, you can change the editor to use by defining environment variables VISUAL or EDITOR. I decided to add the line
export VISUAL=emacs
to the file .bashrc in my home directory. Now pressing v opens the file in Emacs.
No comments:
Post a Comment