Make vim commands work on initial window like NERDTree, MiniBufExplorer and CtrlP does -


i have nerdtree , minibufexplorer open @ launch of vim, have 3 windows. whenever use aforementioned plugins files/buffers presented in correct window, initial one. whenever use command such :e ~/.vimrc command works on window contains cursor. means have remember move cursor on window used editing. wondering if there way have commands work on window regardless of cursor is, or if file buffers automatically present in window?

i looking @ way have cursor move on right window when : (or other key use) pressed, couldn't figure out way there no way identify windows (or there?).

files, buffers, , splits oh my!

you asking vim change how every single file , buffer command change accommodate plugin choice , workflow. going against vim way here , hinder use of vim's splits.

first things first realize vim has no concept of project drawers, splits/windows. means nerdtree , other plugins go great lengths emulate project drawer behavior , fail.

lets @ problems using nerdtree , minibufexplorer open windows:

nerdtree:

  • wasted space. how @ file structure? 10% of time? less?
  • splits - open few split switch bottom right split via <c-w>b. open file via nerdtree in window. did use <c-w>t go top left window? feels quite nuance use many window commands open file
  • nerdtree doesn't play when rearranging splits. create splits <c-w>j or <c-w>h. see how messed layout

minibufexplorer

  • scale - minibufexplorer doesn't scale number of buffers. have opened on hundred buffers without issue. can not imagine waste of space cause minibufexplorer
  • there little gained seeing open buffers time. need see them when switching different buffer
  • switching buffers - can switch buffers mapping :bnext , :bprev commands
  • more on switching buffers - moving minibufexplorer window tedious , annoy if how want switch buffers
  • rearranging windows - same nerdtree
  • minibufexplorer akin using vim's tabs each file in vim see: use buffer effectively

the vim way

as laid out in vimcast post, oil , vinegar - split windows , project drawer, vim prefers open file explorer when need switch away when isn't needed. can user nerdtree in fashion too, forget alway on file explorer bit. there other ways of opening files in vim:

  • use file completion, via <tab>, commands :e , :sp
  • use <c-d> instead of <tab> list of completions
  • :e , :sp commands take globs. e.g. :e *.c , :e foo/**/bar.c
  • :find , setup 'path' , 'suffix' options
  • ctags or cscope jump tags
  • gf go file under cursor
  • look fuzzy finders ctrlp or command-t
  • create project specific navigation via projectile (rails example of this)

there plenty of ways switch buffers in vim:

  • :b , :sb take buffer numbers names complete , glob
  • use :ls see list of buffers use :b switch directly
  • <c-6> go the previous buffer
  • map :bnext , :bprev example [b , ]b unimpaired.vim mappings
  • set hidden make switching buffers easier. don't worry vim let know if have unwritten buffer before exiting
  • once again fuzzy finder plugsin ctrlp , command-t switch buffers

vim split happy. make sure use splits can. there many split commmands, see :h opening-window. better yet read whole :h window file, there many treasure in there.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -