8 cheatsheet snippets

emacs cursor movement shortcuts

  • M-g g <N> or M-g M-g <N> -- go to line (goto-line)
  • M-g c <N> -- go to character (goto-char)
  • M-g <TAB> <N> -- go to column in the current line

  • M-< -- beginning-of-buffer

  • M-> -- end-of-buffer

  • C-a or <home> -- move-beginning-of-line

  • C-e or <end> -- move-end-of-line

  • C-f or <right> -- forward one char (forward-char) or right one char (right-char). (Note right-char moves backward when editing right-to-left text.)

  • M-f or M-<right> or C-<right> -- forward one word (forward-word) or right one word (right-word).
  • C-b or <left> -- backward one char (backward-char) or left one char (left-char). (Note left-char moves forward when editing right-to-left text.)
  • M-b or M-<left> or C-<left> -- back one word (backward-word) or left one word (left-word).

  • C-n or <down> -- down one line (next-line)

  • C-v or <PageDown> -- down one page (scroll-up-command)
  • C-p or <up> -- up one line (previous-line)
  • M-v or <PageUp> -- up one page (scroll-down-command)

  • C-x C-n -- set current column as "goal" column for up/down movement

  • C-u C-x C-n -- cancel current goal column
Published 15 Mar 2013
Tagged emacs and cheatsheet.

 

Searching in Emacs

  • C-s / C-r -- search / search backward in current buffer
  • M-s o / M-x occur / M-x ioccur -- list lines in current buffer matching regexp
  • M-x rgrep -- recursive grep (find in files)
Published 23 Mar 2013
Tagged emacs and cheatsheet.

 

various emacs shortcuts

  • In org-mode, <s[tab] inserts a BEGIN_SRC/END_SRC block. (Think "insert source".)
  • Bookmarks
    • C-x r b - jump to bookmark
    • C-x r m - create (make) bookmark
  • M-o M-s / M-o M-S - center line / center paragraph
  • M-<Home>, M-<Page Up>, etc. - move in other window/frame (without losing focus on the current window/frame)
  • cursor movement

    • C-a / C-e - beginning of line / end of line
    • M-a / M-e - beginning of sentence / end of sentence
    • C-b / C-f - backward one character / forward one character
    • C-p / C-n - previous line / next line
  • C-l - recenter top/bottom

  • C-j - newline and indent
  • C-c h - hide lines matching
  • C-h e - show echo area messages
Published 12 May 2013

 

Spell checking cheat-sheet for emacs.

  • M-$ - ispell-word or ispell-region (depending on whether something is selected)
  • [SPACE] - Skip this word—continue to consider it incorrect, but don't change it here.
  • r newword [RETURN] - Replace the word, just this time, with new. (The replacement string will be rescanned for more spelling errors.)
  • R new [RETURN] - Replace the word with new, and do a query-replace so you can replace it elsewhere in the buffer if you wish. (The replacements will be rescanned for more spelling errors.)
  • a - Accept the incorrect word—treat it as correct, but only in this editing session.
  • A - Accept the incorrect word—treat it as correct, but only in this editing session and for this buffer.
  • i - Insert this word in your private dictionary file so that Aspell or Ispell or Hunspell will consider it correct from now on, even in future sessions.
  • m - Like i, but you can also specify dictionary completion information.
  • u - Insert the lower-case version of this word in your private dictionary file.
  • l word [RETURN] - Look in the dictionary for words that match word. These words become the new list of “near-misses”; you can select one of them as the replacement by typing a digit. You can use * in word as a wildcard.
  • C-g X - Quit interactive spell checking, leaving point at the word that was being checked. You can restart checking again afterward with C-u M-$.
  • x - Quit interactive spell checking and move point back to where it was when you started spell checking.
  • q - Quit interactive spell checking and kill the spell-checker subprocess.
  • ? - Help

Via the emacs FAQ.

Published 14 May 2013
Tagged emacs and cheatsheet.

 

Cheat Sheet for JavaScript Regular Expressions

flags

  • /pattern/g - global
  • /pattern/i - case-insensitive
  • /pattern/m - multi-line

patterns

  • \s - any whitespace character ([\f\n\r\t\v\u00A0\u2028\u2029])
  • \S - any non-whitespace character ([^\f\n\r\t\v\u00A0\u2028\u2029])
  • [\s\S] - commonly used for "anything including newlines (alternative [^])
  • \S - any non-whitespace character ([^\f\n\r\t\v\u00A0\u2028\u2029])

  • \w - any word character (alpha, numeric or underscore) ([a-zA-Z0-9_])

  • \W - any non-word character ([^a-zA-Z0-9_])
  • \d - any digit ([0-9])
  • \D - any non-digit ([^0-9])
  • \cX- control character X (e.g. \cM matches control-M (^M))
  • \b - word boundary (the position between a word char and whitespace)
  • \B - not a word boundary ([^\b]).
  • \xhh - the character with hex code hh
  • \uhhhh - the character with hex code hhhh
Published 18 Jan 2013

 

Cheat Sheet for Linux Run Levels

"Standard" Linux uses the following run levels:

  • Run Level 0 is halt (shutdown).
  • Run Level 1 is single-user mode.
  • Run Level 2 is multi-user mode (without networking)
  • Run Level 3 is multi-user mode (with networking). This is the normal "terminal" mode. (I.e., before the display manager is run).
  • Run Level 4 is undefined.
  • Run Level 5 is multi-usermode with a GUI display manager (X11).
  • Run Level 6 is reboot.

In Debian and its derivatives run levels 2 thru 5 are the same: multi-user mode with networking, and with a display manager if available.

  • Run Level 0 is halt (shutdown).
  • Run Level 1 is single-user mode.
  • Run Level 2-5 is multi-user mode with networking and a GUI display manager when available.
  • Run Level 6 is reboot.

Debian also adds Run Level S, which is executed when the system first boots.

Also see Wikipedia's article on run levels.


 

Some 'awk' basics

Extract tab delimited fields from a file:

$ awk -F"\t" '{print "field one=" $1 "; field two=" $2 }' file
Tagged linux, awk, tool and cheatsheet.

 

A Cheat Sheet for SQLite

General

  • Most of the SQLite "meta" commands begin with a dot. When in doubt, try .help
  • Use Ctrl-d or .exit or .quit to exit (and Ctrl-c to terminiate a long-running SQL query).
  • Enter .show to see current settings.

Meta-data

  • Enter .databases to see a list of mounted databases.
  • Enter .tables to see a list of table names.
  • Enter .index to see a list of index names.
  • Enter .schema TABLENAME to see the create table statement for a given table.

Import and Export

  • Enter .output FILENAME to pipe output to the specified file. (Use .output stdout to return to the default behavior or printing results to the console.)
  • Enter .mode [csv|column|html|insert|line|list|tabs|tcl] to change the way in which query results are printed.
  • Enter .separator DELIM to change the delimiter used in (list-mode) exports and imports. (Defaults to |.)
  • Enter .dump [TABLEPATTERN] to create a collection of SQL statements for recreating the database (or just those tables with naames matching the optional TABLEPATTERN).
  • Enter .read FILENAME to execute the specified file as a SQL script.
Published 18 Sep 2013

 

This page was generated at 4:16 PM on 26 Feb 2018.
Copyright © 1999 - 2018 Rodney Waldhoff.