Wednesday, December 23, 2009

Re: Not necessarily a "question" - but need help nonetheless

On Wed, Dec 23, 2009 at 08:53:19AM EST, Jon Trelfa wrote:
> On Wed, Dec 23, 2009 at 2:25 AM, Chris Jones <cjns1989@gmail.com> wrote:

> > Just a quick update to mention that I installed NERDTree, and as I
> > suspected, when restoring a previous session, it comes up with an
> > empty side bar.

> > ... As an aside, this is a great plugin, bu I noted that on my
> > hardware running terminal Vim, loading large directories is very
> > slow, to the point that I probably will not use it. The problem here
> > is usability rather than the actual measured slowness, since it is
> > not _that_ slow. But because everything else in terminal Vim is so
> > very fast, I found that it was kind of breaking my rhythm to the
> > point that on a couple of occasions I lost my train of thought.
> >

> You bring up a great point - which is the root of where I'm having
> difficulty - work flow. the NERDTree plugin is great for me because
> it's a quick and easy way to browse my file system and open files.
> There's a couple of "limitations" that I'm sure I could figure out but
> that's not the point. I don't think I need to be more proficient at
> using that particular plugin - I need to figure out a faster workflow
> using vim! :)

> So - is there a better way to deal with managing a folder full of files?
>
> For example, I use CodeIgniter PHP framework. I regularly switch between
> files in different directories:
> system
> application
> controllers
> views
> models
> public
> css
> js

> the NERDTree gives me a nice way to navigate the folder structure.
> You said it yourself, though--- it's just slow enough that it broke
> your train of thought - maybe I'm just missing a key feature of vim?

Where slow is concerned, the feature might be that Bram does not favor
the idea of turning vim into an IDE, or so I heard.. All the same, even
if vimscript is not C, I am quite shocked at how long it takes to load a
100-file or so directory.. feels like minutes and must be something like
five seconds, on my laptop.

> My workflow:

> editing system/application/controllers/home.php
> "i need to add a login screen"
> create system/application/views/login.php and add the necessary code
> "I need access to the database"
> create system/application/models/user.php and add code
> "I need to open the form validation config file"
> open system/application/config/form_validation.php
> etc...

Once the directory is loaded, hjkl + go or Ctrl-W l/j, Ctrl-O to go back
to editing previous files, etc. is quite fast really. I'm so used to the
Ctrl-W windowed mode shorcuts that I find them quicker than reaching for
a mouse, with the added time savers that (1) I don't have to take my
hands off thekeyboard, and (2) I don't have to mentally switch modes.

The above workflow would be something like:

:NERDTree ~/system/application

[down to controllers subfolder - hit <O>] # open recursive
[down to controllers/home.php - hit <s>] # split vertical + open
[...]
[back to NERDTree panel <Ctrl-W h>]

[down to views/login.php - hit <o> # reuse same window

etc.

One possible improvement might be if you could jump directly to a file
or directory by line number - i.e. if you have asked NERDTree to display
line numbers, and application is line 53, just [53O] would open the
sub-tree, and likewise, if home.php shows up on line 67, [67s] would
open your first source file.

I'm surprised the author(s) have not considered this feature, which I
use frequently in my mailer, because in the above example, hitting
53O67s, which is only six key strokes would present you with home.php
ready to edit. True this works better if you are a seasoned typist with
good hand-to-eye coordination.

But if you feel more comfortable with a mouse, it seems that NERDTree
also provides the feature, where you can double-click to open folders or
directories.

> In a previous life full of graphical IDEs and heavy mouse usage, I
> would just double-click on the file(s) and start editing. The "vim
> way" - at least for now - is a lot slower for me to move around.

I think you can be just about as quick with either the mouse or
keyboard, although I favor the latter. I guess if keyboard navigation is
not second nature, it may take time before you become as comfortable as
you are with a mouse.

> Back to the question, then... is there a better/faster way for me to
> move around and open files in the various directories without having
> to type :e
> ~/public_html/project_folder/system/application/controllers/home.php
> when I need to open a file?

I'm not sure about the Vim way, but I guess if you want to cut down on
the number of keystrokes, some variation on the following would achieve
this:

:map <Leader>C1 :lcd /frequently/used/project/directory1<Enter>
:map <Leader>C2 :lcd /frequently/used/project/directory2<Enter>

:map <Leader>NT<Enter>

Unless you have changed the <Leader> default, you would type to open
the NERDTree panel on e.g. ~/public_html/../../application/

\C1
\NT

Hit 'O' to open all subfolders recursively and you are able to quickly
access individual files in any subfolder of ../../application.

:help leader

Mind you, this is just for example's sake. I'm no expert and likely
there are more elegant ways to speed up the process, or make it more
user-friendly.

I haven't looked at it yet, but NERDTree has a bookmark feature that
might make things easier than my example mappings.

:help NERDTreeBookmarks

CJ

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment