|
 |
CS313 Tips and Hints |
Printing tips
lpr -Pminir Myfile.java |
prints the file Myfile.java to the printer minir single-sided |
a2ps -2 -Pminir Myfile.java |
prints the file Myfile.java to the printer minir using a 2 pages/page and double-sided format |
lpq -Pminir |
lists the item in the printer's queue |
lprm 349 |
removes the item -- specified by the job number -- from the printer's queue (can only be done by the user who placed it in the queue) |
Printer names
s160a |
name of printer in the lab room |
sciliba (scilibb, scilibe) |
science library printer A (and B, and E) |
minir (minil) |
mini focus printer on the right (on the left) |
e101 |
science center printer outside of E101 |
Linux hints
-
pwd prints your current working directory , e.g. pwd might produce this: /students/wwellesle/cs313/assignment4
-
ls -lt lists your files, one per line, with the most recently edited one first.
-
cat prints the contents of a file to the screen , e.g. cat Myfile.java
-
more prints the contents of a file to the screen, one screenful at a time. Spacebar moves to the next screen, "q" quits the more, e.g. more Myfile.java
> Output redirection, e.g. java Cyberspace URLlist.txt > tmp
-
head Shows 1st 10 lines of a file [e.g. head jobs.txt]
-
tail Shows last 10 lines of a file [e.g. tail jobs.txt]
- wget [e.g.
wget image.jpg]
Let's say you want to grab a picture of Brian from the web. Here's
one in this page. The path for this image (which you can glean from viewing the source code) is: http://cs.wellesley.edu/~btjaden/pictures/tjaden.jpg
Try this in linux (all on one line):
wget http://cs.wellesley.edu/~btjaden/pictures/tjaden.jpg
and then type "ls" to see what files you now have (and think carefully about the pictures you post online).
-
C-r (Control r) [linux] allows you to search back through the linux commands
that you have typed (similar to yanking with the up arrow key, but can search through your history).
cmp fileA.java fileB.java [linux] Shows the first line number where the two files differ.
diff fileA.java fileB.java [linux] Displays the lines that differ between two files.
Here are some simple examples using diff.
-
M-x calendar Displays a calendar (C-x < or C-x > to scroll)
find Finds files or directories (and more).
-
find . -name 'SequenceOps.java' searches all subdirectories of the current (.) directory.
-
find . -name '*.java' lists all .java files in the current directory and subdirectories.
-
find ~ -daystart -type f -atime 1 lists all files that were accessed yesterday
-
man find for more information about find
-
spell filename.txt lists misspelled words in filename.txt
who Lists other users logged onto your machine.
-
date Prints the date and time.
-
cal Prints calendar for given month and year, e.g. cal 10 2008
Emacs hints
- Marking for cut and paste using the keyboard
why? mucho faster than using the mouse. really.
- Place the cursor at the start of the region that you want to cut
- Press Ctrl+Spacebar (at the same time)
On Macs, this often brings up the search window. If this happens, use Ctrl+@
- It should say Mark set in the modeline, as shown
here:
- Move your cursor to the end
of the desired cut area
- Ctrl-W kills the area
- To
paste it back in, move your cursor to the place where you'd like to
insert
- Ctrl-Y will yank the killed text back (as many
times, and in as many places as you'd like: each Ctrl-Y inserts
another version of your cut text -- note that you can yank the code into different documents too)
- Just a reminder: you can customize your
.emacs file in your home
directory. Here is a code snippet of my .emacs
- To see the list of your color choices, do ESC (let go) X and then type "list-colors-display" (without quotation marks) and hit return.
- To change the color of strings in emacs, add this line to your .emacs
(remember that your .emacs lives in your home directory):
(set-face-foreground 'font-lock-string-face "steel blue")
To see the list of colors, M-x list-colors-display.
- ESC (let go) Q reformats text in your file,
getting rid of those pesky wrapped lines
- Ctrl-s Searches in
your file. Type Ctrl-s and then type the string (or fragment
of a string that you are looking for). You can repeatedly hit
Ctrl-s to find the next occurrence of the string in your
document. The search will wrap back up to the top of the document as
well.
M-x query-replace [emacs] This is like replace-string except that
Emacs asks you whether or not it's ok to replace each occurrence. Useful because sometimes you want to do
a nearly global replace, and this is exactly the right command.
-
C-x 2 Splits window horizontally
-
C-x 3 Splits window vertically
-
C-x o (oh, not zero) Switch between windows
-
C-x f Find the file for your newly opened window
-
C-x 1 (one) Revert to a single window
- Adding a prefix to each line (e.g. //)
-
C+space to mark the first line
- Move cursor to the beginning of the last line
-
M-x string-rectangle and then type what you'd like to insert
- Delete the first few n chars of every line
-
C+space to mark the first line
- Move the cursor to the last line, and move it right n chars
-
M-x kill-rectangle and then those chars will evaporate from each line
-
M-x ispell-buffer allows you to step through each
misspelled word in your file and offers substitute words.
| |
|
|