Posts tagged spacemacs

spacemacs: essentials

posted on 2016-01-16 12:20

foreword

Spacemacs is a truly awesome piece of software. It is literally the best of both worlds from vim and emacs.

In the last years I have heavily used (and customized) vim (my .vimrc is about 900 lines). But as soon as you want to do more complex stuff, which involves a lot of plugins, things get ugly and slow. Often you also happen to need a custom compiled vim (so it has python bindings enabled) and bad hackery (vimscript is an absolute traffic accident).

After quite some stints with emacs in the last years (interest in lisp plus the customization which is possible with it, compared to vimscript) and a lot of pulling hair out due to debugging problems (When is a major/minor-mode actually loaded? Packages broken when using the different package universes like melpa/elpa/marmalade together? Evil-mode not working in all buffers even though it was set globally?) I stumbled upon Spacemacs.

common solutions for common problems

helm keybind popup too slow

See ~/.spacemacs:

dotspacemacs-which-key-delay 0.01

syntax highlighting for special files lacking

Put this into ~/.spacemacs in the user-config() section:

(autoload 'markdown-mode "markdown-mode"
  "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.post\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))

font too large

See ~/.spacemacs, same section:

(defun dotspacemacs/user-config ()
       (set-face-attribute 'default nil :height 80)
)

Here 10 ~= 1pt, so 80 is like 8pt from what I read.

start maximized

See ~/.spacemacs:

dotspacemacs-maximized-at-startup t

custom bindings

Canonical example here shall be using 'jk' simultanously to exit from INSERT mode. For that the key-chord package is needed, plus a little configuration.

See ~/.spacemacs:

(defun dotspacemacs/user-config ()
       (key-chord-define-global "jk" 'evil-normal-state)
       (key-chord-mode t)
       ...
)
(defun dotspacemacs/user-config ()

is the place to go. If you for example need additional packages without grouping them into a layer, put them under dotspacemacs-additional-packages, also in .spacemacs.

dotspacemacs/user-init vs. dotspacemacs/user-config

user-config gets loaded at the end of the parsing of the config file contents, whereas user-init right at the beginning. Usually you want to place code into user-config.

keybinds essentials list (beside original vim stuff)

ESC             abort current menu
C-g             abort current menu
C-h u           go back to previous helm menu

SPC f f         open file
SPC f s         save file

C-x C-c         close spacemacs

# window management
SPC w /         create vertical window split
SPC w -         create horizontal window split
SPC w c         window close

SPC TAB         switch to last buffer
SPC b b         buffer list
SPC b n         next buffer
SPC b p         previous buffer
SPC f d         kill/delete buffer

SPC <number>    jump to window <number>
SPC w arrow     move to window up/left/righ/down
C-w hjkl        move to window up/left/righ/down
SPC w S-arrow   move window up/left/righ/down
SPC w c         close window

# open and reload dotfile
SPC f e d       open
SPC f e R       reload dotfile

# using the help for looking up things, the shortcut is:
SPC h d f       help describe function
SPC h d k       help describe key
SPC h d p       help describe package
SPC h d m       help describe mode
SPC h d v       help describe variable
C-h a           emacs 'apropos'

keybinds additionals list (non-geeks safely forget everything past here...)

HUD

SPC t f         toggle show indicator at 80 chars and disable soft-wrapping
SPC t h h       toggle show cursorline
SPC t i         toggle show indent guide
SPC t h a       toggle automatic symbol highlighting
SPC f t         toggle neo-tree (folder browser)

editing

SPC n r         narrow region (just show current selection)
SPC n f         narrow function (just show current function)
SPC n w         widen again

syntax checking

SPC t s         enable flycheck

This blog covers .csv, .htaccess, .pfx, .vmx, /etc/crypttab, /etc/network/interfaces, /etc/sudoers, /proc, 10.04, 14.04, AS, ASA, ControlPanel, DS1054Z, GPT, HWR, Hyper-V, IPSEC, KVM, LSI, LVM, LXC, MBR, MTU, MegaCli, PHP, PKI, R, RAID, S.M.A.R.T., SNMP, SSD, SSL, TLS, TRIM, VEEAM, VMware, VServer, VirtualBox, Virtuozzo, XenServer, acpi, adaptec, algorithm, ansible, apache, apache2.4, apachebench, apple, applet, arcconf, arch, architecture, areca, arping, asa, asdm, autoconf, awk, backup, bandit, bar, bash, benchmarking, binding, bitrate, blackarmor, blockdev, blowfish, bochs, bond, bonding, booknotes, bootable, bsd, btrfs, buffer, c-states, cache, caching, ccl, centos, certificate, certtool, cgdisk, cheatsheet, chrome, chroot, cisco, clamav, cli, clp, clush, cluster, coleslaw, colorscheme, common lisp, configuration management, console, container, containers, controller, cron, cryptsetup, csync2, cu, cups, cygwin, d-states, database, date, db2, dcfldd, dcim, dd, debian, debug, debugger, debugging, decimal, desktop, df, dhclient, dhcp, diff, dig, display manager, dm-crypt, dmesg, dmidecode, dns, docker, dos, drivers, dtrace, dtrace4linux, du, dynamictracing, e2fsck, eBPF, ebook, efi, egrep, emacs, encoding, env, error, ess, esx, esxcli, esxi, ethtool, evil, expect, exportfs, factory reset, factory_reset, factoryreset, fail2ban, fbsd, fdisk, fedora, file, filesystem, find, fio, firewall, firmware, fish, flashrom, forensics, free, freebsd, freedos, fritzbox, fsck, fstrim, ftp, ftps, g-states, gentoo, ghostscript, git, git-filter-branch, github, gitolite, global, gnutls, gradle, grep, grml, grub, grub2, guacamole, hardware, haskell, hdd, hdparm, hellowor, hex, hexdump, history, howto, htop, htpasswd, http, httpd, https, i3, icmp, ifenslave, iftop, iis, imagemagick, imap, imaps, init, innoDB, innodb, inodes, intel, ioncube, ios, iostat, ip, iperf, iphone, ipmi, ipmitool, iproute2, ipsec, iptables, ipv6, irc, irssi, iw, iwconfig, iwlist, iwlwifi, jailbreak, jails, java, javascript, javaws, js, juniper, junit, kali, kde, kemp, kernel, keyremap, kill, kpartx, krypton, lacp, lamp, languages, ldap, ldapsearch, less, leviathan, liero, lightning, links, linux, linuxin3months, lisp, list, livedisk, lmctfy, loadbalancing, locale, log, logrotate, looback, loopback, losetup, lsblk, lsi, lsof, lsusb, lsyncd, luks, lvextend, lvm, lvm2, lvreduce, lxc, lxde, macbook, macro, magento, mailclient, mailing, mailq, manpages, markdown, mbr, mdadm, megacli, micro sd, microsoft, minicom, mkfs, mktemp, mod_pagespeed, mod_proxy, modbus, modprobe, mount, mouse, movement, mpstat, multitasking, myISAM, mysql, mysql 5.7, mysql workbench, mysqlcheck, mysqldump, nagios, nas, nat, nc, netfilter, networking, nfs, nginx, nmap, nocaps, nodejs, numberingsystem, numbers, od, onyx, opcode-cache, openVZ, openlierox, openssl, openvpn, openvswitch, openwrt, oracle linux, org-mode, os, oscilloscope, overview, parallel, parameter expansion, parted, partitioning, passwd, patch, pct, pdf, performance, pfsense, php, php7, phpmyadmin, pi, pidgin, pidstat, pins, pkill, plasma, plesk, plugin, posix, postfix, postfixadmin, postgres, postgresql, poudriere, powershell, preview, profiling, prompt, proxmox, ps, puppet, pv, pveam, pvecm, pvesm, pvresize, python, qemu, qemu-img, qm, qmrestore, quicklisp, quickshare, r, racktables, raid, raspberry pi, raspberrypi, raspbian, rbpi, rdp, redhat, redirect, registry, requirements, resize2fs, rewrite, rewrites, rhel, rigol, roccat, routing, rs0485, rs232, rsync, s-states, s_client, samba, sar, sata, sbcl, scite, scp, screen, scripting, seafile, seagate, security, sed, serial, serial port, setup, sftp, sg300, shell, shopware, shortcuts, showmount, signals, slattach, slip, slow-query-log, smbclient, snmpget, snmpwalk, software RAID, software raid, softwareraid, sophos, spacemacs, spam, specification, speedport, spi, sqlite, squid, ssd, ssh, ssh-add, sshd, ssl, stats, storage, strace, stronswan, su, submodules, subzone, sudo, sudoers, sup, swaks, swap, switch, switching, synaptics, synergy, sysfs, systemd, systemtap, tar, tcpdump, tcsh, tee, telnet, terminal, terminator, testdisk, testing, throughput, tmux, todo, tomcat, top, tput, trafficshaping, ttl, tuning, tunnel, tunneling, typo3, uboot, ubuntu, ubuntu 16.04, udev, uefi, ulimit, uname, unetbootin, unit testing, upstart, uptime, usb, usbstick, utf8, utm, utm 220, ux305, vcs, vgchange, vim, vimdiff, virtualbox, virtualization, visual studio code, vlan, vmstat, vmware, vnc, vncviewer, voltage, vpn, vsphere, vzdump, w, w701, wakeonlan, wargames, web, webdav, weechat, wget, whois, wicd, wifi, windowmanager, windows, wine, wireshark, wpa, wpa_passphrase, wpa_supplicant, x11vnc, x2x, xfce, xfreerdp, xmodem, xterm, xxd, yum, zones, zsh


Unless otherwise credited all material Creative Commons License by sjas