Friday, February 10, 2006

vim file-explorer

VIM has always been my favourite text editor. As a programmer, i enjoy the power it gives me through features like regular expression search, word completion, beautiful highlighting, auto indentation, macro definitions, system shell interface etc. vim being a command prompt tool, all these features come at the cost of getting used to some key combinations. Some people feel it is not worth to break ones head in remembering some *weird* key strokes to do things as simple as editing a text file. Such people prefer using graphical editors like kate, which also provide some of these good features in an easy to use menu option or through an intuitive shortcut. And if you are a java programmer it is always an advantage to use IDEs like eclipse or netbeans which come bundled with tons of features like object browser, method completion, syntax checker, exhaustive code formatter, debugger etc. But we all know the amount of resources these powerfull IDEs require to provide all these flashy features. But the command line tools like vim are the only hope when you are required to connect to a remote m/c through telnet or ssh and are devoid of the luxuries of graphical user interfaces. Having said all that, i still appreciate GUI tools and so i use the Gvim - a more convinient version of vim, for text-editing and eclipse for java programming. This way i can always remain in a familiar environment whether it is a local desktop or a remote ssh session. Being forced to use MS windows at work, i hate to find my explorer going for a toss every now and then for reasons beyond my comprehension. So i tried out some replacements like servant salamander but ended up using by favourite text editor also as a file browser. VIM has a very useful *file-explorer* plugin which can be used for browsing or exploring directories or files. This file-explorer plugin comes in the default vim installation. This is lauched when you open a directory in vim or by pressing :E in vim. If you are using Gvim then you can even click on the names of the files to open them. There is a preview option in which it splits the window and displays the contents of the selected file in the newly created buffer. This is particularly useful when you are trying to look at the contents of a bunch of text files. To realise the utility of this embedded vim file-explorer think of a case when you have a directory containing 100s of text files and you have to search for certain file names and examine their contents. With vim you can do a simple regular expression search for the file name in that directory, preview its contents and then move on to next matching file name. Doing the same thing using the windows explorer and an external editor is quite a task. Some basic vimrc options to customise the *file-explorer* behaviour:-
let g:explVertical=1 " Split vertically
let g:explSplitRight=1    " Put new window to the right of the explorer
To get the complete list of options type :help file-explorer in vim. Similar documentation can also be found at http://www.vim.org/htmldoc/pi_expl.html PS: I have avoided mentioning emacs - "the extensible, customizable, self-documenting real-time display editor", because i found it too complex to handle.

9 Comments:

Anonymous Venu said...

Basically my problem with vi is that I havent figured out an efficient way to cut/copy arbitrary blocks of text (the way you can do in GUI editors using shift key). I dont want too much customization because you dont have the settings you are used to on other's computers or when you connect to remote computers.

2/10/2006 11:26:00 PM  
Blogger Chandan R said...

In Gvim you can do that too..
You can use shift and arrow keys to select text, Ctl-c to copy, Ctl-v to paste, Ctl-x to cut etc...

2/11/2006 05:04:00 AM  
Blogger pvncad said...

venu,
You can try this,(in normal mode)
press v (enter visual mode) where u want to start copying
press movement keys until reach end of the region(h,j,k,l,$,arrowkeys)
then yank it (press y)
then paste it (press p or P)

And also, copying and pasting in vim is much much faster than any normal text editors

2/11/2006 05:04:00 AM  
Anonymous Venu said...

Chand,

You say that a big reason to learn vi properly is that its the only hope when you're connected to remote machines etc, and I agree with you. I wont be having access to gvim in such cases. In fact, I dont have gvim in the Solaris machines I work on, although there is vim -g. Shift selection doesnt work in vim -g.

Praveena,
And Visual mode doesnt work in the primitive VI either. I guess you'll just have to sacrifice somethings when you're working on slow connections. We've had our discussions regarding vi, so lets not redo it here.

2/11/2006 07:03:00 AM  
Blogger Rajat said...

Somehow I don't like using gvim. It becomes kinda unintuitive when you try to use a console utility in a window (at least for me). The file explorer plugin is good.

Vi is unbeatable. Simple & powerful. But when it comes to proper window based text editors, I prefer KWrite. Emacs is of course incomprehensible.

The worst editor out there is Notepad. It beats any other editor hollow. Next would be Wordpad.

2/11/2006 09:45:00 AM  
Anonymous Venu said...

well, notepad and wordpad arent meant for programming purposes. In terms of IDEs, I've heard people saying Visual Studio beats everything else hollow. MS basically put its money where it was worth it.

2/11/2006 11:30:00 AM  
Blogger Gubbi said...

eclipse rules anyday :-)

2/25/2006 08:19:00 AM  
Blogger Chandan R said...

Yes eclipse is great.
But it takes up lot of resources.
I am trying out netbeans -- another free ide from sun. Looks good and importantly light. But still i am not been able to review all its features.

2/26/2006 10:57:00 PM  
Blogger Gubbi said...

yeah, had to upgrade my RAM to 1GB for normal work in eclipse. Our offices can afford anyway :-)

2/27/2006 04:49:00 AM  

Post a Comment

<< Home

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.