MaiaVictor
MaiaVictor

Reputation: 53037

Multi-level folding and Search Everything features from Sublime Text Editor alternatives on VIM?

Multi-level folding enables you to fold everything at a level by pressing a hotkey. It is being useful to get an overview of your code, like this one: http://o7.no/N72vMK

Go to anything is pressing Alt+P. This enables you to quickly go to any file typing part of it's name ('teshtm' would jump to 'test.html') and even to any function in your file.

Upvotes: 0

Views: 1084

Answers (2)

romainl
romainl

Reputation: 196789

multi-level folding

Use zM and zR to close and open all the folds in the current buffer. That's the equivalent of ST2's "Fold all" and "Unfold All".

Use : set foldlevel=x to close everything after level x. :set fdl=0 would close everything while :set fdl=999 would open everything. That's the equivalent of "Fold Level x".

See :help fold.txt and :help 'foldlevel'.

As for everything, you can create custom mappings for all of that if you think that's too much typing. Notice however that you can use zm and zr to increment and decrement the foldlevel.

Alt+P (Ctrl+P on Linux)

I love the aforementioned CtrlP which I use for opening files, navigating buffers, navigating tags, etc. It's very well designed and intuitive. Some people complain about its lack of speed in large projects… my projects are relatively small so I can't really comment on this.

It has a rather big advantage over ST2's implementation: file navigation is not restricted to the current project. If you open a single file in ST2, you can't use CtrlP (on Linux) to open a nearby file: you must open a folder or create a project. or use the regular "Open File…" UI. "Go to anything" is a bit of a stretch, here.

Here is how I use CtrlP:

,ffo<CR> open foo.txt
,bba<CR> jump to buffer bar.txt
,tba<CR> jump to function baz() in curent buffer
,Tfo<CR> jump to function foo() in project

There are actually many plugins exploring the same idea: Command-T, LustyExplorer, FuzzyFinder, etc. Be sure to try all of them before you jump on the {pluginname} bandwagon.

Keep in mind that Vim's default file navigation is quite nice in its own right: :e filename, :e fi<Tab>, :e *na<Tab>

Upvotes: 3

Rook
Rook

Reputation: 62568

I don't use Sublime text much (tried it only for a short time) but "multi-level folding" you can achieve just by folding to a certain foldlevel in Vim.

As far as the other (go to file) thing, similarly, you can achieve it by just using gf function and for example CtrlP plugin. The idea behind CtrlP originated from Textmate from Mac. I don't personally use it, but some people like the principle and swear by it ... from what I've seen it is implemented very nicely for those that like that kind of navigation.

Upvotes: 3

Related Questions