spacemacs 學習筆記

install

  • git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
  • pacman -S emacs
  • 變動軟件 源,編輯.spacemacs,參考.將下列代碼添加到.spacemacs中的dotspacemacs/user-init()
(setq configuration-layer--elpa-archives
    '(("melpa-cn" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")
      ("org-cn"   . "http://mirrors.tuna.tsinghua.edu.cn/elpa/org/")
      ("gnu-cn"   . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")))

basic editing

  • 新建文件python

    • spc f f
    • e path
  • 保存編輯linux

    • spc f s
    • :w
  • 關閉 buffergit

    • spc b d
  • 安裝對應的語法擴展github

    • 打開對應後綴的文件,spacemacs會自動安裝
  • Dired(file or directory navigator)shell

    • spc a d啓動 Dird
    • 經常使用操做編程

      • 搜索文件,/
      • 打開文件,Enter
      • 複製文件,光標移動到指定文件處,shift c
      • 移動重命名文件, 光標移動到指定文件處, shift r
      • 刪除文件,光標移動到指定文件處,shift d
      • 使用外部程序打開文件,光標移動到指定文件處,!
  • buffervim

    • 在emacs中編輯的內容所在的對象爲buffer
    • spc Tab返回上一緩衝區
    • spc b b顯示緩衝區列表,enter可進入
    • spc b d關閉緩衝區
  • windowswindows

    • spc w -上下劃分
    • spc w /左右劃分
    • 移動窗口ssh

      • spc num,num爲窗口標號
      • spc w h/j/k/l,上下左右移動
      • C w h/j/k/l,上下左右移動
    • spc w d關閉窗口
  • Projectile參考函數

    • spc p f 打開文件
    • git respotitory會被識別爲工程文件
  • search text

    • / vim 方式檢索
    • spc s g p project中
    • spc s g g 當前文件中查找
    • spc / 同上
    • spc * 多文件中 查找 光標下的單詞
    • spc s g b 在buffers 查找
    • 更多操做,查看spc s g下的菜單
  • Magic git

    • install

      • 編輯.spacemacs文件,dotspacemacs-configuration-layers
      • uncomment git;:w保存; spc f e R更新文件
    • 基礎操做

      • spc g s開啓magit-status
      • g r更新目錄提交狀態
      • commit

        • git add:光標移動到指定文件處,s
        • commitc c
        • 填寫信息
        • , c提交
        • l l顯示提交記錄
        • 在提交處enter顯示提交細節
      • branch

        • b c 建立新的分支
        • b b 移動新的分支
        • m m 合併分支
        • b x 刪除分支
      • remote repo

        • magit-status
        • M a 輸入ssh地址,https不太方便,老是讓輸入用戶名,密碼
        • P p push
        • F p pull
        • :magit-clone xxxx克隆遠程倉庫
      • squash commit

        • r i 啓動 rebase
        • 在某個起點提交, 輸入C-c C-c
        • 將須要的壓縮的提交前輸入s
        • , c編輯提交信息,便可
        • 注意:squash前面的提交不能所有爲squash
      • Neotree

        • spc f t 打開 neotree 窗口
        • spc 0移動到左側樹形窗口
        • j or <down>: move blow
        • k or <up>:move up
        • Enter open file or directory
        • R 將光標處文件夾設爲根目錄
        • K 將根目錄設爲上層目錄
        • spc p t 將當前工程目錄設爲根目錄
      • org-mode

        • 編輯.spacemacs,取消 org 註釋,spc f e R安裝軟件包
        • Tab open or collapse title.
        • Todolist

          • 在任何標題上面按t 來改變Todolsit:變爲todo;變todo爲done;變todo爲open;
          • 在任何標題上面按, s,進行scheduled,設置開始時間
          • agenda file

            • .spacemacsuser-config 添加 .org 路徑;spc f e R 更新;
            • spc a o o 根據命令面板,顯示相應的信息(agenda 表示scheduled)
            • 顯示信息上面按t更新條目對應狀態
      • shell

        • :ansi-term 運行系統shell
        • :eshell 運行spacemacs自帶的shell,能夠執行lisp語句
        • .spacemacsdotspacemacs-configuration-layers部分取消對shell部分的註釋。

          • 可以使用spc '打開小型的shell(linux 默認的shell)
          • 在以下片斷設置默認的shell,eshell爲emacs的shell,shell爲系統默認shell

            (shell :variables
                    shell-default-shell 'eshell
                    shell-default-height 30
            )
          • spc p '在當前工程根目錄打開shell
      • 在同一位置打開shell,暫時不須要,跳過
      • color theme 配置顏色主題

        • dotspacemacs-configuration-layers中添加themes-megapackspc f e R更新(時間較長)
        • spc T s預覽theme,theme預覽網址
        • 在文件dotspacemacs-theme處配置
      • 一次編輯多行

        • visual-mode

          • 移動到須要修改的字段
          • v 進入visual-mode
          • Ctrl + v 進入 visual-block
          • j 向下移動選中多行
          • I 返回第一行進行同步修改
          • ESC 應用修改到多行
        • IEDIT

          • 移動到須要修改的字段
          • spc s e 進入IEDIT-state
          • (經常使用的移動方式)或者(n, N)移動到選中的字段,使用TAB鍵能夠激活/取消激活選中字段
          • I 進入編輯模式
          • F 將搜索限制在單個函數中

python 配置

  • 配置:dotspacemacs-configuration-layers

    • 基本語法高亮 python
    • 自動補全 auto-completion
    • 語法檢查syntax-checking
  • 執行 SPC f e R 更新設置
  • 快捷鍵:

    • , h h : 查找文檔
    • , g a : 查找變量的賦值語句
    • , g u : 查找全部引用
  • REPL(Read-Eval-Print Loop) "讀取-求值-輸出" 循環 交互式編程環境

    • spc m s i 開啓交互式編程環境
    • spc m s b REPL運行當前窗口代碼並獲取其上下文。spc m s B相似
    • spc m s f 將單個函數放入REPL
  • live coding(好像不支持 if __name__ == "__main__")根據改動實時執行代碼

    • spc m l 啓動/關閉 live coding
相關文章
相關標籤/搜索