This is a simple kakoune cheat sheet to help me (and readers) remember some very useful features.
To see kakoune in action.
Commands (in command mode)
Select from START to END position.
Use `Z` to mark start and `alt+z i` to select unti current position.
Add a vertical cursor (useful to mimic rectangle operation)
Type `C` to add a new cursor below your current cursor.
Clear all cursors
Type `space` to remove all cursors except one.
Pasting text verbatim (without completion/indentation)
You have to use "disable hook" command before inserting text. This is done with `\i` with `\` disabling hooks.
Split selection into cursors
When you make a selection, you can use `s` and type a pattern, this will create a new cursor at the start of every pattern match.
This is useful to make replacements for words or characters.
A pattern can be a word, a letter, or even `^` to tell the beginning of each line.
In kakoune there are often multiples way to do operations.
Select multiples lines
Go to first line, press `J` to create cursors below and press `X` to select whole lines of every cursors.
Using start / end markers
Press `Z` on first line, and `alt+z i` on last line and then press `X` to select whole lines of every lines.
Press `X` until you reach the last line.
Replace characters or words
Make a selection and type `|`, you are then asked for a shell command, you have to use `sed`.
Sed can be used, but you can also select the lines and split the selection to make a new cursor before each word and replace the content by typing it, using the `s` command.
For my blog I format paragraphs so lines are not longer than 80 characters. This can be done by selecting lines and run `fmt` using a pipe command. You can use other software if fmt doesn't please you.
Here is my git cheat sheet ! Because I don’t like git I never remember how to do X or Y with it so I need to write down simple commands ! (I am used to darcs and mercurial but with the “git trend” I need to learn it and use it).
Undo uncommited changes on a tracked file
$ git reset --hard
Get the latest version before working
$ git pull
Make a commit containing all tracked files
$ git commit -m "Commit message" -a
Send the commit to the repository
$ git push
I am learning mutt and I am lost. If you are like me, you may like the following cheat sheet!
I am using it through imap, it may be different with local mailbox.
Case is important !
- Change folder : Y
- Filter the display : l (for limit) and then a filter like this
- ~d <2w : ~d for date and <2w for “less than 2 weeks” no space in <2w !
- ~b “hello mate” : ~b is for body and the string is something to find in the body
- ~f firstname.lastname@example.org : ~f for from and you can make an expression
- ~s “Urgent” : ~s stands for subject and use a pattern
- Delete messages with filter : D with a filter, if you used limit before it will propose by default the filter of limit
- Delete a message : d (it will be marked as Deleted)
Deleted messages will be removed when you change the folder or if you exit. Pressing $ can do it manually.
I may add new things in the future, as they come for me, if I find new features useful.
How to repeat a command n time
repeat 5 curl http://localhost/counter_add.php
How to expand recursively
If you want to find every file ending by .lisp in the folder and subfolder you can use the following syntax. Using ****** inside a pattern while do a recursive globbing.
Work with temp files
If you want to work on some command outputs without having to manage temporary files, zsh can do it for you with the following syntax: =(command that produces stdout).
In the example we will use emacs to open the list of the files in our personal folder.
emacs =(find ~ -type f)
This syntax will produce a temp file that will be removed when emacs exits.
here is my ~/.zshrc, very simple (I didn’t pasted the aliases I have), I have a 1000 lines history that skips duplicates.
HISTFILE=~/.histfile HISTSIZE=1000 SAVEHIST=1000 setopt hist_ignore_all_dups setopt appendhistory bindkey -e zstyle :compinstall filename '/home/solene/.zshrc' autoload -Uz compinit compinit export LANGUAGE=fr_FR.UTF-8 export LANG=fr_FR.UTF-8 export LC_ALL=fr_FR.UTF-8 export LC_CTYPE=fr_FR.UTF-8 export LC_MESSAGES=fr_FR.UTF-8
Here is a dump of my emacs config file. That may be useful for some emacs users who begin.
If you doesn’t want to have your_filename.txt~ files with a tilde at the end (this is a default backup file), add this
; I don't want to have backup files everywhere with filename~ name (setq backup-inhibited t) (setq auto-save-default nil)
To have parenthesis highlighting on match, which is very useful, you will need this
; show match parenthesis (show-paren-mode 1)
I really like this one. It will save the cursor position in every file you edit. When you edit it again, you start exactly where you leaved the last time.
; keep the position of the cursor after editing (setq save-place-file "~/.emacs.d/saveplace") (setq-default save-place t) (require 'saveplace)`
If you write in utf–8 (which is very common now) you should add this.
; utf8 (prefer-coding-system 'utf-8)
Emacs modes are used depending on the extension of a file. Sometime you need to edit files with a custom extension but you want to use a mode for it. So, you just need to add some line like this to get your mode automatically when you load the file.
; associate extension - mode (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) (add-to-list 'auto-mode-alist '("\\.tpl$" . html-mode))
My Org-mode part in the config file
(require 'org) (define-key global-map "\C-ca" 'org-agenda) (setq org-log-done t) (setq org-agenda-files (list "~/Org/work.org" "~/Org/home.org"))
Stop mixing tabs and space when indenting
(setq indent-tabs-mode nil)