Spacemacs Learning [Spacemacs 学习]

Useful keybinding

Memory

  • SPC f s Save a buffer
  • SPC f S Save all opened buffers
  • SPC b b Open or switch a buffer with helm
  • SPC T h Select a theme using a helm buffer
  • SPC f/p t To toggle the Neotree buffer press (project)
  • SPC h b Open the bookmark
  • SPC h l Resume the last helm buffers
  • SPC s L Focus the last converted search buffer
  • F3 In a helm buffer, convert a helm search buffer into a regular buffer

The Emacs Evil Tutor

LESSON 1

  1. The cursor is moved using either the arrow keys or the hjkl keys. h (left) j (down) k (up) l (right)
  2. To exit Emacs type: <ESC> :qa! <ENTER> to trash all changes. OR type: <ESC> :wqa <ENTER> to save the changes.
  3. Ctrl + f Page Down Ctrl + b Page Up
  4. 0 Cursor to the beginging of the line $ Cursor to the end of the line
  5. G Cursor to the last of the file nG Cursor to the n line of the file gg Cursor to the begin of the file, like 1G

    :[Enter] followed by a line number and moves to that line number. N[Enter] Curosr to the N line

NOTE: Pressing <ESC> will place you in normal state or will cancel an unwanted and partially completed command.

LESSON 2

  1. x/X To delete a character under/before the cursor in normal state type
  2. To delete a whole line type: dd
  3. The format for a command in normal state is:

    [number] command object OR command [number] object where: number - is how many times to repeat the command command - is what to do, such as d for delete object - is what the command should act upon, such as w for word, $ for "to the end of line", etc.

  4. d1G, dG, d0, d$
  5. yy Copy the line of cursokr nyy Copy the n line data
  6. y1G, yG, y0, y$
  7. p/P Paste the data from the next/before line
  8. To undo previous actions, type: u To undo the undo's type: CTRL-R Repeat the last opeartion: .

LESSON 3

  1. To replace text that has already been deleted, type p this puts the deleted text AFTER the cursor (if a line was deleted it will go on the line below the cursor).
  2. To replace the character under the cursor, type r and then the character which will replace the original.
  3. The change command allows you to change the specified object from the cursor to the end of the object. eg. Type cw to change from the cursor to the end of the word, c$ to change to the end of a line.
  4. The format for change is: [number] c object OR c [number] object

LESSON 4

  1. Typing / followed by a phrase searches FORWARD for the phrase. Typing ? followed by a phrase searches BACKWARD for the phrase. After a search type n to find the next occurrence in the same direction or N to search in the opposite direction.
  2. Typing % while the cursor is on a (,),[,],{, or } locates its matching pair.
  3. To substitute new for the first old on a line type :s/old/new To substitute new for all 'old's on a line type :s/old/new/g To substitute phrases between two line #'s type :#,#s/old/new/g To substitute all occurrences in the file type :%s/old/new/g To ask for confirmation each time add 'c' :%s/old/new/gc

LESSON 5

  1. :!command executes an external command.

    Some useful examples are:

    :!ls or :!dir - shows a directory listing.

    :!rm or :!del FILENAME - removes file FILENAME.

  2. :w FILENAME writes the current buffer to disk with file name FILENAME.
  3. :#,#w FILENAME saves the lines # through # in file FILENAME.
  4. :r FILENAME retrieves disk file FILENAME and inserts it into the current buffer following the cursor position.

LESSON 6

  1. Typing o opens a line BELOW the cursor and places the cursor on the open line in insert state. Typing a capital O opens the line ABOVE the line the cursor is on.
  2. Type an a to insert text AFTER the character the cursor is on. Typing a capital A automatically appends text to the end of the line.
  3. i/I Insert text at the character/Not blank

Python and R programming environment configuration

Python

  • Configure the auto-complete mode as the spacemacs layer: auto-complete
  • Replace the keybinding SPC m s i to 'run python' in file package.el within python layer
  • Add the following confirmation to .spacemacs
    (add-hook 'inferior-python-mode-hook 'flycheck-mode)
    (add-hook 'inferior-python-mode-hook 'flyspell-mode)
    

R

  • Add the following confirmation to .spacemacs
(add-hook 'R-mode-hook 'smartparens-mode)
(add-hook 'R-mode-hook 'flycheck-mode)
(add-hook 'R-mode-hook 'flyspell-mode)
(add-hook 'org-mode-hook 'smartparens-mode)
(add-hook 'inferior-ess-mode-hook 'company-mode)
(add-hook 'inferior-ess-mode-hook 'smartparens-mode)
(add-hook 'inferior-ess-mode-hook 'flycheck-mode)
(add-hook 'inferior-ess-mode-hook 'flyspell-mode)
  • For the R auto complete: after open the R file, then C-c C-c, reopen the R file
  • When insert src-block with org heading, add a , before the heading, to avoid mistake

Creative Commons licensing

TITLE: Spacemacs Learning [Spacemacs 学习]
AUTHOR: lengyueyang
DATE: 2016-02-14 19:26:52 UTC+08:00
UPDATED:
LICENSE: The blog is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License, commercial use is not allowed, for any reprint, please indicate address and signature. 88x31.png

Comments

Comments powered by Disqus