Spacemacs - General Discussion, Blog Posts, Wiki

Tags: #<Tag:0x00007f11429e0020> #<Tag:0x00007f11429dfdc8>


I’m still getting used to Spacemacs’ configuration, so I’ll focus less on where it should go and more on what Emacs needs.

(defun shell-in-directory ()
  (let* ((orig-default-dir default-directory)
         (default-directory (read-string "Directory: " orig-default-directory)))

Then M-x shell-in-directory will prompt you for the desired directory, defaulting to the current default-directory.

I tried adding a custom keybinding for SPC " like this, but it fails saying SPC isn’t a prefix key.

(global-set-key (kbd "SPC \"") #'shell-in-directory)

Adapt as necessary to Spacemacs conventions for adding or overriding leader bindings.


Does anyone know where I need to put this?

  ;; Allow hash to be entered  
  (global-set-key (kbd "M-3") '(lambda () (interactive) (insert "#")))

I’ve tried it in dotspacemacs/user-init and dotspacemacs/user-config but it doesn’t work.

On UK keyboards the hash key is ALT + 3 - all I get is it trying to go to window 3, hence trying the code above.


Do you have to press shift+3 on UK keyboards to get #?

If so you probably need to use (kbd "M-#") and Alt+Shift+3. In Emacs land chords involving characters requiring a shift key don’t explicitly mention Shift.

You can also check what key chord Emacs registers by pressing C-h k and then the key chord you want to verify. This also tells you what commands, if any, are currently bound to the chord.


No, Shift+3 gives us the pound symbol £
Alt+3 gives us the # - well usually :lol:

Running C-h k gives me:

M-3 runs the command select-window-3 (found in window-numbering-keymap), which
is an interactive Lisp function in ‘window-numbering.el’.

It is bound to SPC 3, M-m 3, M-3.

(select-window-3 &optional ARG)

Select the window with number 3.

Which is what I am getting. However I just want Alt+3 to give me the # key.

Apparently the code in my previous post works - which makes me think I am putting it in the wrong place?


I’m still getting up to speed with Spacemacs configuration conventions (just started using it), but you might want to try putting it in ~/.spacemacs.d/init.el. Create the directory if it doesn’t already exist.


There isn’t a spacemacs directory just a .spacemacs file…

I did put it in .emacs.d/init.el (also other things I have been trying as well) and nothing I’ve put in there has worked either.

From the docs:

7.5.1 Configuration functions

Three special functions in the ~/.spacemacs file can be used to perform configuration at the beginning and end of Spacemacs loading process:

  • dotspacemacs/layers is called at the very startup of Spacemacs initilialization, this is where you set the Spacemacs distribution and declare layers to be used in your configuration. You can also add or excluded packages of your choice and tweak some behavior of Spacemacs loading.
  • dotspacemacs/init is called at the very startup of Spacemacs initialization before layers configuration. You should not put any user code in there besides modifying the Spacemacs variable values prefixed with dotspacemacs-.
  • dotspacemacs/user-init is called immediately after dotspacemacs/init, before layer configuration. This function is mostly useful for variables that need to be set before packages are loaded.
  • dotspacemacs/user-config is called at the very end of Spacemacs initialization after layers configuration. This is the place where most of your configurations should be done. Unless it is explicitly specified that a variable should be set before a package is loaded, you should place your code here.


There wasn’t for me either, but Spacemacs loads its init.el file if it exists.

I’m not sure why it’s not working–maybe somebody else more familiar with Spacemacs and/or UK keyboards has an idea.


I went in their Gitter chat and they told me that emacs keybindings are hierarchical and there are many active at once - generally speaking the ones that are more broadly active have lower priority, so global will have the lowest priority for instance. It starts with highest priority, checks for key, then it goes through the next, and so on.

So the code I actually needed was this:

 ;; Allow hash to be entered
  (define-key window-numbering-keymap (kbd "M-3") nil) 
  (global-set-key (kbd "M-3") (lambda () (interactive) (insert "#")))

The first line unbinds the higher priority keymap
The second binds what I want in the global keymap



Going back to this… it’s something that’s already built in as well :044:

Simply use SPC p ' which makes sense, duh!


I currently using diff-hl instead of git-gutter.

it is the only working solution for me, and it has good on-the-fly checking, means that i don’t need to save the file to see the change/diff. It is working well with flycheck as well.

here is my .spacemacs, in case you want to know:


I have a big problem. When using spacemacs on Ubuntu 16.04 it crashes and freezes deadly so often. Usually when I use SPC s s

Any suggestions what to do?


I don’t have any problem on KDE neon (Ubuntu 16.04 core), but try with debug option to track any error


Thanks for this thread! I have been using spacemacs for probably close to a year and I had never seen the words NeoTree before. Wow!
Also, I hadn’t installed Ag on this computer yet. spc s p is much faster now!

There are a few posts here about commenting lines. I usually comment lines by:

  • Highlighting in visual (line) mode (shift v)
  • spc ;

page up and page down are ctrl-b and ctrl-f

But I think I should get more used to using Swoop (spc-s-s) and Avy (spc-j)


Almost 5 days working online using spacemacs and now I’m thinking. Why? Why I never tried it sooner :smiley: Currently no plans to go back to VS Code :smiley:


VS Code has better js support :wink: and also I like markup edit in split window view. Working with markup in space macswas not so pleasant. But I use both editors with pleasure.


Has anyone been able to configure smartparens to highlight do-end blocks on cursor? My setup seems to only highlight def*-end block, which comes out ugly:

Not a showstopper, but annoying nonetheless. Somehow the auto-completion works fine (doRET inserts end).


Based on the photo it looks like it’s matching against the wrong “end” too–yuck!


Yes, that was the problem, since for each def* it looks for a closing end, and it matches the first end it could find without respecting the dos :cry:


Got it. I initially misinterpreted and thought you wanted do highlighted instead of def.


Uh, no, you’re not actually misinterpreting me :slight_smile: I wanted it to highlight do-end blocks instead of def*-end blocks, but as it is now the def*-end block highlighting is not even correct. I suppose it is derived from Ruby’s highlighting and broken with Elixir.