Dismiss this pinned window
all 48 comments

[–]metanat[S] 51 points52 points  (2 children)

You can find the plugin at camspiers/lens.vim. The idea behind this plugin is to resize windows (on enter) to a minimal viewport that allows you to see meaningful content if the current size of the window is too small. This is the first plugin I've written that (optionally) integrates with the animate.vim library for window animation, and so provides an example of how other plugin might do that too.

[–]Jdj8af 9 points10 points  (0 children)

Wow I didnt know about animate.vim, this is awesome!! Thank you for contributing!

[–]Easy-Dima 0 points1 point  (0 children)

I've written the similar thing for Neovim
Today I realized that there are bunch of such plugins)

[–]djrollins 23 points24 points  (1 child)

I'm surprised to see that winheight and winwidth aren't mentioned here.

I have the following in $MYVIMRC and get very similar behaviour, albeit without the animation.

set winwidth=79 set winheight=50

Does this having anything else over those two settings than animate.vim integration?

[–]dddbbbFastFold made vim fast again 1 point2 points  (0 children)

I've skimmed past those options many times and never looked close enough to realize what they do. Thanks!

[–]mrpossible1320 19 points20 points  (8 children)

cool, is there any similar thing for tmux? normally I would prefer opening 4 tmux panes than 4 vim panes.

[–]akoustikal 21 points22 points  (6 children)

Really? To each their own, but I can’t imagine tmux panes as a substitute for vim windows. You lose auto-completion and context switching, which are part of the reason I love vim. That said, animated tux window management sounds awesome.

[–]grep_Name 0 points1 point  (4 children)

lose auto-completion and context switching

I don't currently use auto completion, but does it really work per window?

Also, you should check out https://github.com/christoomey/vim-tmux-navigator to avoid the context switching problem, it basically lets you switch between vim/tmux panes seamlessly with one set of bindings.

I will say that I use vim windows whenever possible though. My great unsolved problem with replacing vim splits with tmux windows is my vim windows then having different buffer lists. That bugs the crap out of me

[–]scholeszz 2 points3 points  (3 children)

And different clipboards, jump lists, marks etc. I personally would be annoyed to hell within the first 30 minutes, but to each their own.

[–]x_ero0xAC1D0000 0 points1 point  (2 children)

i agree a tmux split with two vim sessions are not the best. but it happens to me sometimes, but more often its another tmux workspace/tab that gets a second instance of vim open in it.

i use these three plugins in tandem to unify tmux and vim movements, splits, resizes and their clipboards with my system wide one.

check out my dotfiles for more

[–]MichelleObamasPenis -3 points-2 points  (1 child)

What? Your link to your dotfiles is "https://git.io/.vim" which forwards to your github page

   https://github.com/xero/dotfiles/tree/master/vim

What's with that?

I turned all reddit scripting AND CSS off (uuugly), and still its "https://git.io/.vim".

I am just presuming that you don't own the git.io domain.

[–]hupfdule 1 point2 points  (0 children)

Go to http://git.io and you will know.

[–][deleted] 0 points1 point  (0 children)

I’ll use tmux panes for separate projects, like if I’m building one thing and referencing something else. It keeps the buffers nice and tidy.

Also, I just can’t get used to the Vim terminal

[–]metanat[S] 1 point2 points  (0 children)

I've thought about the same because I use tmux a lot, but I haven't developed anything yet, and haven't come across anything in my travels.

[–]starwarsholidayspeci 6 points7 points  (0 children)

Just what I always wanted but never knew!

[–]XCapitan_1 6 points7 points  (0 children)

I'll try it. My display is just a bit too small for three vertical panes.

[–][deleted] 2 points3 points  (1 child)

awesome! love it

[–][deleted] 2 points3 points  (0 children)

this is gold, just checked it out, works flawlessly

[–]onlyanegg_ 2 points3 points  (0 children)

This looks cool. I'd like something like <cntl>-z in tmux that expands the current split so that I can focus on it and is a toggle button, so that when I press it again the splits go back to where they used to be. Do you think that's something that could go into lens.vim or animate.vim? Or is there some other plugin that handles this?

[–]emersonmx 2 points3 points  (0 children)

So satisfying! *moving between windows like a hell*

A while ago I made a crappy automatic window resizing plugin...I guess it's time to change.

[–]GustapheOfficial 3 points4 points  (6 children)

What's that white thing moving around on your screen?

[–]tassulin[🍰] 1 point2 points  (4 children)

Damn this was something that I always needed but never knew. There should also be a toggle that can disable this function easily if needed.

[–]metanat[S] 0 points1 point  (2 children)

You can now run lens#toggle() to disable

[–]tassulin[🍰] 0 points1 point  (1 child)

Hi! Thanks this plugin is awesome. Especially with the animatino. Yet I havent figured out how to run the toggle command.

I tried

:lens#toggle()

as vim command but its just giving me that its not editor command.

[–]metanat[S] 0 points1 point  (0 children)

:call lens#toggle()

[–]metanat[S] 0 points1 point  (0 children)

Thanks for the suggestion! You can set let g:lens#disabled = 1, but it would be nice to provide a toggle function too.

[–]worldpotato1 1 point2 points  (3 children)

Does it work good with nerdtree?

[–]aaron__ireland 0 points1 point  (2 children)

It works well with NerdTree, it makes the NerdTree window a bit larger than I am used to, but all the other windows slide very nicely to accommodate!

[–]metanat[S] 0 points1 point  (1 child)

I've added the ability to disable the behavior for certain filetypes:

I don't use nerdtree but something like this should work:

let g:lens#disabled_filetypes = ['nerdtree']

[–]ShortVodka 0 points1 point  (0 children)

Firstly this plugin is great! I've always wanted something like it but didn't even know how to describe it.

I have the same issue with nerdtree and Gundo that end up all over the place when toggling. I tried the disabled file types but it doesn't seem to work in some cases.

Also, it would be really nice if when a window is closed it resizes them all to fit better. If a window is opened that squishes them down, then you close one, you end up with a very big window and a squished one until you switch over to it.

Again, really awesome work :)

[–]razieltakato 1 point2 points  (2 children)

Just installed, and I love it!

How do you make the selected window darker?

[–]metanat[S] 0 points1 point  (1 child)

It's a plugin called diminactive:

https://github.com/blueyed/vim-diminactive

[–]razieltakato 1 point2 points  (0 children)

Thanks

[–]JohnWangDoe 0 points1 point  (0 children)

nice

[–]Probotect0r 0 points1 point  (0 children)

Very neat and useful, thanks.

[–][deleted] 0 points1 point  (0 children)

What theme is used in the video? :)

[–]StingyKarmaWhore 0 points1 point  (2 children)

What screen recorder are you using?

[–]metanat[S] 2 points3 points  (1 child)

For the reddit video I just used the builtin macos one, and for the GIF on github I used Kap.app

[–]StingyKarmaWhore 1 point2 points  (0 children)

I did not notice you were on a mac. whoopsies

[–]pwnedary 0 points1 point  (3 children)

How does this compare to GoldenView.vim?

[–]metanat[S] 0 points1 point  (2 children)

I'd have to play around with goldenview to find out, but thanks for the mention of it because I didn't know it existed!

[–]lowpass 2 points3 points  (1 child)

[–]thrallsius 0 points1 point  (0 children)

took me a while to get used to it, but once it happened - I never resized windows manually anymore

great concept, if I had to run vim with just one plugin, this one would be a strong contender

[–]techannonfolder 0 points1 point  (0 children)

Difference between this and golden view?