Emacs - shortcuts for horizontal and vertical separation

I switch to emacs from vim and in my .vimrc, I have the following shortcuts for horizontal and vertical split screen:

" Create window splits easier. The default
" way is Ctrl-w,v and Ctrl-w,s. I remap
" this to vv and ss
nnoremap <silent> vv <C-w>v
nnoremap <silent> ss <C-w>s

      

How can I do this in emacs?

+3


source to share


2 answers


Welcome to Emacs - I see from the several previous questions you are using evil

, the Vim emulation level. Here's a short version:

(define-key evil-normal-state-map "vv" 'split-window-horizontally)
(define-key evil-normal-state-map "ss" 'split-window-vertically)

      



Look EmacsWiki page on evil

, and (unfortunately outdated) Zlovoe guide .

I also suggest looking at the source evil

to understand how to do things like key bindings using a function find-library

. M-x find-library RET evil

and M-x find-library RET evil-maps

should start working.

+4


source


If you are not planning on using any vim emulation mode for Emacs, for example evil-mode

, you might be interested in the standard way of splitting windows:



  • C-x 2- split-window-below

    (vertical split)
  • C-x 3- split-window-right

    (horizontal division)
  • C-x 0- delete-window

    (removes the current window)
  • C-x 1- delete-other-windows

    (forces the current window to fill the frame)
+4


source







All Articles