Tuesday, September 12, 2017

Netrw cheatsheet

To toggle netrw explorer window add this code into your .vimrc:
" Toggle explore with Ctrl-e
function! ToggleExplorer()
  if exists("t:expl_buf_num")
      let expl_win_num = bufwinnr(t:expl_buf_num)
      if expl_win_num != -1
          let cur_win_nr = winnr()
          exec expl_win_num . 'wincmd w'
          close
          exec cur_win_nr . 'wincmd w'
          unlet t:expl_buf_num
      else
          unlet t:expl_buf_num
      endif
  else
      exec '1wincmd w'
      Explore
      let t:expl_buf_num = bufnr("%")
  endif
endfunction
map <silent> <C-e> :call ToggleExplorer()<CR>

<c-e> - open netrw (:Explore vim-command)
- - up one directory
u - change to recently-visited directory
U - change to subsequently-visited directory
qf - display information on file

d - make a directory
% - open a new file in netrw’s current directory
R - rename the file/directory under cursor
D - remove the file/directory under cursor

mf - mark a file
mr - mark files satisfying a shell pattern
mp - print marked files
mu - unmark all marked files
mt - dir under cursor becomes markfile target
mc - copy marked files to markfile target

me - place marked files on arg list and edit them
mx - apply arbitrary shell command to marked file

p - preview file content.
<c-w>z - close preview window.

Changing colorscheme in Ranger

If you want to change the colorschemen in Ranger filemanager just add 'set colorscheme jungle' into the ~/.config/ranger/rc.conf