Workspace efficiency - Vim tip 1 of 3
This is my first tip for advance usage of the Vim editor. It's meant for people that are already comfortable with Vim.
Requirements:
Check out Vim documentation if you need help. The ideaThe general idea is to have a workspace! This is crucial if you use one Vim window. You can use multiple Vim windows, but this has a number of drawbacks:
Here is how my Vim looks like and what we are aiming at:
Getting mini buffer explorerThis is a little script that lets you explore your buffers. I use it to have an overview over what files are currently open. Download from Vim's site minibufexpl.vim. There is a guide on how to install it. My configuration of this script (place this inside your .vimrc file): let g:miniBufExplModSelTarget = 1 let g:miniBufExplorerMoreThanOne = 0 let g:miniBufExplModSelTarget = 0 let g:miniBufExplUseSingleClick = 1 let g:miniBufExplMapWindowNavVim = 1 let g:miniBufExplVSplit = 25 let g:miniBufExplSplitBelow=1 map <c-w><c-t> :WMToggle<cr> It's crucial that you know how to delete (close) buffers - without closing the window. If you don't: Deleting a buffer without closing the window... Using tabsI use Vim tabs when I am working on different parts of the same problem domain. For C you would have one tab for a header and another for the actual code. In MVC architecure you could have 3 tabs: view, controller and model. Etc. To make it convinient here are my tab hotkeys: map <leader>tn :tabnew %<cr> map <leader>tc :tabclose<cr> map <leader>tm :tabmove Now to open a new tab you just type ,tn in normal mode. My mapleader is ,. Command line surfingVim command line is very powerful. I only use the command line to locate files, and I am pretty happy with the efficiency. An animation (and introduction) of how I locate files and directories: Command line completionVim has excellent documentation, read about command line compeltion here. Ok, you read it? Well, notice Ctrl-D hotkey... This one is really nice :) Before I come with an example, put this in your .vimrc: set wildmenu This will display command-line results in a wild menu :) After this is done go to command line mode and do this: :e ~/Desktop/<CTRL-D> CTRL-D is of course Control and D pressed togheter. Watch the result and I think you will have a pretty good understanding why CTRL-D is useful. Notice: CTRL-D isn't the same as tab completion. Tab completions completes, CTRL-D shows you the available completions. Lovely mappingsTo speed things up I use some mappings, here are some really simple and useful command line mappings: cno $h e ~/ cno $d e ~/Desktop/ cno $$ e ./ I.e. pressing $d prints out e ~/Desktop/! Notice: I have remapped the key below ESC to $, so pressing $ is lighting fast!
VIM Editor
•
9. Aug 2006
17 comments so far
Post a comment
Commenting on this post has expired.
|
Blog labels |