0

I have recently started learning Vim, and I don't like the default key-mapping of splitting windows in Vim. That is, I don't like to enter C-w and then S for horizontal and v for vertical, and moving focus by C-w jkhl or up-down,left-right.

I will like to have 'h' for splitting horizontally and 'v' for splitting vertically when in Normal Mode, without entering C-w. How can this be done? And also, does anyone know of a sane-ish config for changing focus in windows, because I am not sure if that makes sense without C-w.

Thanks.

1
  • Changing mappings can cause problems as other plugins override them There are plugins eg github.com/wesQ3/vim-windowswap that help with moving windows. and things like nmap <leader>s<left> :leftabove vnew<CR> that maps ,s<left> to create a new buffer on the left above. I use , as my leader
    – Steve
    Dec 7, 2020 at 23:35

1 Answer 1

0

This isn't a good answer as I can't remember where I got these from but in my _vimrc (.vimrc on windows)

This lot moves between buffer ie Alt right arrow moves to the next buffer right etc

    nmap <silent> <A-Right> :wincmd l<CR>
    nmap <silent> <A-Up> :wincmd k<CR>
    nmap <silent> <A-Down> :wincmd j<CR>
    nmap <silent> <A-Left> :wincmd h<CR>

Update Vim uses a concept of a leader, ie a standard key followed by another key(s), to make commands easier. See :h <Leader>. It defaults to backspace in the default installation i use let mapleader = "," as I find ,sw(leftarrow) easier than backspace(leftarrow). What it means is for eg nmap <leader>q :q!<cr> means typing ,q quits the current buffer without saving it. END Update

These commands remaps vim commands to a shorter command using the leader command eg to create new buffer at the top left of your buffers use leader>sw<left> where <left> means the left arrow

    nmap <leader>sw<left>  :topleft  vnew<CR>
    nmap <leader>sw<right> :botright vnew<CR>
    nmap <leader>sw<up>    :topleft  new<CR>
    nmap <leader>sw<down>  :botright new<CR>
    nmap <leader>s<left>   :leftabove  vnew<CR>
    nmap <leader>s<right>  :rightbelow vnew<CR>
    nmap <leader>s<up>     :leftabove  new<CR>
    nmap <leader>s<down>   :rightbelow new<CR>
3
  • I didn't understand the <leader> part of your answer. I am a beginner, so can you please re-explain in simpler terms?
    – LordRishav
    Dec 8, 2020 at 4:21
  • Hi. Hope the update helped.
    – Steve
    Dec 8, 2020 at 22:20
  • I'm no longer a programmer and even when I was I hated speaking in *nix speak, which help files are written in, so my answers are based on English :)
    – Steve
    Dec 9, 2020 at 23:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .