Managing Your Splits In Vim

Поділитися
Вставка
  • Опубліковано 20 кві 2020
  • In this video, I cover some of the basics regarding splits in Vim. I show you some of my settings in my vimrc that makes some things easier when working with splits.
    REFERENCED:
    ► gitlab.com/dwt1/dotfiles/-/bl... - My Neovim config
    WANT TO SUPPORT THE CHANNEL?
    💰 Patreon: / distrotube
    💳 Paypal: www.paypal.com/cgi-bin/webscr...
    🛍️ Amazon: amzn.to/2RotFFi
    👕 Teespring: teespring.com/stores/distrotube
    SOCIAL PLATFORMS:
    🗨️ Mastodon: mastodon.technology/@distrotube
    💬 IRC: irc://freenode #distrotube
    👫 Reddit: / distrotube
    📽️ LBRY: lbry.tv/$/invite/@DistroTube:2
    DT ON THE WEB:
    🕸️ Website: distrotube.com/
    🐿️ Gopherhole: gopher://distro.tube
    📁 GitLab: gitlab.com/dwt1
    FREE AND OPEN SOURCE SOFTWARE THAT I USE:
    🌐 Brave Browser - brave.com/dis872
    📽️ Open Broadcaster Software: obsproject.com/
    🎬 Kdenlive: kdenlive.org
    🎨 GIMP: www.gimp.org/
    🔊 Audacity: www.audacityteam.org/
    💻 VirtualBox: www.virtualbox.org/
    Your support is very much appreciated. Thanks, guys!
  • Наука та технологія

КОМЕНТАРІ • 148

  • @andrewpalm2103
    @andrewpalm2103 4 роки тому

    Thanks, Derek. I appreciate you going over the various split commands. Good refresher.

  • @craigw4644
    @craigw4644 4 роки тому +3

    Nice job, very helpful, your mapping method is simple compared to others found online.

  • @henninb
    @henninb 4 роки тому +3

    Vim tutorials are always good. Thanks for sharing.

  • @x3mboy
    @x3mboy 4 роки тому

    This is really useful! I usually use buffers in a tab-like mode, but splits well used will be useful for me.

  • @busdriver1261
    @busdriver1261 3 роки тому +4

    Didn't know about the :terminal command - thanks for that tip! I used to type Ctrl-Z, do my stuff and go back to vi using fg command in the window. Having it in a split is handier :)

  • @parsarch6546
    @parsarch6546 4 роки тому +8

    Only thing I needed right now

  • @KevinBReynolds
    @KevinBReynolds 4 роки тому +1

    Very cool DT. Thanks again.

  • @ooogabooga5111
    @ooogabooga5111 2 роки тому +1

    thq so much for this, as a new vim lover, this was a huge help

  • @kellingc
    @kellingc 4 роки тому

    This is awesome. Thanks for posting this.

  • @modaryaghi
    @modaryaghi 4 роки тому +1

    Thanks a lot. Your videos are the best for learning vim stuff.

  • @surajkumarbarnwal6303
    @surajkumarbarnwal6303 2 роки тому

    This really helped a lot, thanks for the video!

  • @lucminax
    @lucminax 4 роки тому +4

    I find using file-specific marks (with uppercase letters as mark names) more interesting than splits for most of my use cases. Of course some cross-referencing and diff-ing can benefit from having all side to side, but I usually want to focus on one thing at a time. Having the marks allows for quick, specific buffer jumping without having to find it with :b, with added benefit of having a specific line selected

  • @subarutendou
    @subarutendou 4 роки тому

    nice! I just start using vim splite today, because tire of swithing the windows. this give me more info. The split terminal really handy, i dont need to open another terminal for occationally compile the program that take up the space anymore.

  • @SoundToxin
    @SoundToxin 4 роки тому

    You can also resize with C-w + and C-w - to move them slightly, and the typical vim repeat behavior works on window actions as well, so sometimes I'll type something like 10 or 50 and then do one of those binds and it's as if I hit them that many times. You can also include moving between splits in your vim macros which is really cool. I've used it for macros that delete a line from two files open next to each other, saves them and puts me back where I started.

  • @AnzanHoshinRoshi
    @AnzanHoshinRoshi 4 роки тому

    Thank you, Derek.

  • @kekistanimythology5833
    @kekistanimythology5833 4 роки тому

    that was super useful for me, thanks.

  • @azadpoursadegh9761
    @azadpoursadegh9761 3 роки тому

    Awesome I really enjoyed, I usually use tmux or byobu but this is way easier.

  • @lsatenstein
    @lsatenstein 4 роки тому +6

    I watch everyone of your youtubes. I use vim, and I did learn somethings today. May I make a comment or two? When you edit together the little snippets into the longer one, please allow 1/4 second between topic changes. Watch your UA-cam of this topic. If I was to take notes, for my needs, it would was difficult. I stopped, backed up and replayed.
    My other question is to say, the corona virus may be a good thing for you. We say Canadians say "When one door closes, another door opens". The future looks bright.
    Take care.
    Leslie from Montreal

    • @bryanhoffman4331
      @bryanhoffman4331 4 роки тому +1

      It's helpful to slow the video down to 0.75%. I did that and was able to follow along very nicely.

  • @migtrewornan8085
    @migtrewornan8085 4 роки тому

    I hate key chords so I remapped w to . . . maybe it's not a great idea but I find it works for me.

  • @arjsan2
    @arjsan2 4 роки тому

    Thanks DT this help me lot on vim splits... :)

  • @achimmeyer9889
    @achimmeyer9889 3 роки тому

    thanks! solid work!

  • @wilhelmngoma9009
    @wilhelmngoma9009 Рік тому +1

    Thanks for sharing

  • @Raekh_
    @Raekh_ 2 роки тому +1

    The only guy I've ever heard who said viyum instead of vim

  • @rmdashrfv
    @rmdashrfv 4 роки тому +1

    Goddamn, I love this channel

  • @jaumaakajmc
    @jaumaakajmc 4 роки тому +1

    I really like your videos DT! Thanks for sharing :)
    I'm having some problems with the remapping. The resizing don't work at all in urxvt (they put me in insert mode and inputs "a","b","c","d" in different lines), but they do in termite, any idea why? Also, the navigation mapping does not work while the rest do... What am I missing here? Thanks!

  • @noobsaibot8723
    @noobsaibot8723 4 роки тому +1

    seriously dunno why iv not been using splits. always been ctrl-shift -pgdown. Thanks.

  • @macfhlannchadharonan4668
    @macfhlannchadharonan4668 4 роки тому +1

    How do you manage to get the terminal to not open a new vim instance? I remember looking into neovim-remote but never got it working in the end.

  • @Phydoux2112
    @Phydoux2112 4 роки тому +1

    I need to play with vim more.

  • @hanspetervollhorst1
    @hanspetervollhorst1 4 роки тому

    exclusively uses tiling window managers. still gets excited about splits and running shells inside vim. personally I find that a very emacs-y approach to vim

  • @cocorico128
    @cocorico128 4 роки тому +4

    how are you able to learn so many pieces/aspects of software so quickly?

  • @pdote
    @pdote 4 роки тому +44

    Now I have one question: why should I use splits in vim instead of using multiple windows in a tiling wm?

    • @DistroTube
      @DistroTube  4 роки тому +43

      Just off the top of my head, copying and pasting (yanking and putting, that is) between documents is easier is they are in the same vim instance.

    • @DistroTube
      @DistroTube  4 роки тому +26

      Simply doing "yy" for yank line and "pp" for put only works inside your current vim instance. To copy and paste between two different instances of vim, you have to copy to a different register. So you would have to do something like "+yy (copy to the + register) and "+p (paste from + register).

    • @chopcooey
      @chopcooey 4 роки тому +13

      as a vim user, i hate vim splits. I need to use them because that's just how you do things with vim but as a long term goal i plan on switching to something that works differently, maybe vis. My problem with splits, first of all is that split commands are badly intertwined with buffer commands, i.e. closing a buffer (:bd) will also close the split when it should definitely not and you need custom commands to avoid this behavior. And more importantly, between tiling wms and terminal multiplexers, there is a ton of ways to manage your split layout among your whole workflow in a single and much better way. The very idea that a text editor is doing window layout management is not Unix-like and honestly requiring an extra layer of hotkeys to manage windows at it's own level. The problem is that you cannot really do otherwise with vim, since the whole vim session (variables, paths, open buffers) is bound to the vim layout of the instance running. What i would prefer, and that's why im looking to switch eventually, is to have a text editor that runs in a client-server like architecture, where you can open as many new instances of the editor as you want that have access to everything on a server through IPC, i.e. an instance of the editor is just a viewport of the actual editor server running in the background. Then you do your tiling with tmux or w/e.

    • @amrsoll
      @amrsoll 4 роки тому +9

      I don't see a good reson why you shouldn't have the + buffer as the default buffer for copy-pasting... Why didn't the UNIX philosophy include "Fool-proof defaults"?

    • @brianfiszman3179
      @brianfiszman3179 4 роки тому +2

      I just find it more comfortable and faster, and I do use it a lot. In fact, is one of my favorite features really.
      When you are coding in a large codebase, you will find yourself splitting screens a lot mostly if you learned how to do it efficiently with the right keystrokes.
      Its not only a matter of yanking and pasting but about speed, opening another instance of nvim in tmux and getting to the file you wanna open is much slower than opening nerdtree and pressing "s" or "i" for splitting, or using a ag with fzf and using a shortcut to open a new buffer in a split window.
      Also, closing a buffer is really quick if you configured yourself a shortcut yourself to do the job. I use Ctrl-C for that.
      Cmon, u gotta admit, its just better and faster than using tmux.

  • @danihp9238
    @danihp9238 4 роки тому +2

    amazing video thanks, i think i will say goodbye to tmux

  • @jeffreymerrick4297
    @jeffreymerrick4297 4 роки тому +1

    I've found it useful to remap 's' to "control-w'. This has the advantage of shortening all the windows commands in one shot. Typing "s h" is easier than "control-w h" and is even easier than Derek's "control-h" because you don't have to hold the 's' while you press the 'h'
    It's not a great loss if you don't have the regular 's' command because, if you need it, 'cl' can be used as a substitute. :-) See the help page for the 's' command.

    • @SoundToxin
      @SoundToxin 4 роки тому

      In my config I took inspiration from spacemacs and made space the leader key and mapped several of the window binds to spc-w and then something else. Basically what they were in spacemacs.

  • @cwatson411
    @cwatson411 4 роки тому

    The terminal in vim doesn't seem to work for me...? The pane flashes and then just does a normal :vsp
    I wonder if there is something in my vimrc thats conflicting...

  • @IdkIdk-gp8gu
    @IdkIdk-gp8gu 4 роки тому +1

    Can someone explain me why we need tmux when we have splits in vim?

  • @phosphenius7602
    @phosphenius7602 4 роки тому

    What are your thoughts on the end of the Linux Actions News podcast and the reason behind it?

  • @zedrobot5864
    @zedrobot5864 4 роки тому

    Pls make a video on how you costumize your window manager theme

  • @siboliu810
    @siboliu810 2 роки тому

    Great job! Btw anyone know how can i show files names in a new command line when i use split to open new files? Like when i use command line to open new files using tab to show all the flles in current path

  • @nodidog
    @nodidog 3 роки тому

    Sensible config, thanks for the video 👍

  • @deepanshiagrawal5136
    @deepanshiagrawal5136 3 роки тому

    While doing :sp filename , it is opening file in new tab not in split window. Please help me to resolve this issue

  • @fuseteam
    @fuseteam 4 роки тому

    btw :resize 10 makes the pane 10 lines

  • @mustyhead
    @mustyhead 4 роки тому

    I love me some vim learning.
    One thing, though, I'd like to know if it's possible to yank/put among files in separate terminal windows. Sometimes I just prefer to have files open here and there (Sometimes it even makes sense.) and need to copy text from one to the other. While old fashioned copy/paste or middle-mouse paste work too, it'd be nice to treat those separate windows a little like vim splits.

    • @RushilKasetty
      @RushilKasetty 4 роки тому +1

      Copy to your system clipboard

    • @mustyhead
      @mustyhead 4 роки тому

      @@RushilKasetty, thank you.
      I just looked up vim and system clipboard on your suggestion. It looks like I'll have to get used to playing with it, but it looks like the workflow may be much like what I'm used to with y/p.

  • @AndyRufasto
    @AndyRufasto 4 роки тому +2

    I find out ":terminal" opens your terminal in your working directory:
    - me *W*.
    fckng love vim

  • @ironmanlifts
    @ironmanlifts 4 роки тому

    :vert ba open all buffers in vert.Did you leave emacs ? I've never used emacs, mostly vim. I have a function that opens all my last used files in vert, sessions mess me up. Thanks for the videos been using awesome window manager, it's awesome ! I recommend people use the awesome copycats themes to avoid the headaches. Everything comes ready to go and works.

  • @matthewrease2376
    @matthewrease2376 2 роки тому

    I've already remapped control j and k to page down/up :)

  • @amrsoll
    @amrsoll 4 роки тому +6

    Split like Vim Damme

  • @somnvm37
    @somnvm37 7 місяців тому

    I'm not sure how usefill the terminal command is, becuase tmux can help with all that [also theres a plugin for tmux thatll allow you to just use ctrl + hjkl for movement instead of normal tmux stuff]. I also use tabs so having the same terminal on every tab would often be nice. Still a good tip ty 👍

  • @NathanielHarari
    @NathanielHarari 4 роки тому

    Hey DistroTube, since you've gone back to Vim from Emacs as your main editor, I had a question for you: What would you do to replace Org Mode now that you don't rely on Emacs anymore? I'm curious if you ever really got into it, if you have something you recommend, etc.... Just seeing what you have to say or what your experience is since changing etc....

    • @DistroTube
      @DistroTube  4 роки тому

      I don't really use outline tools or notes/appointment apps so org-mode wasn't anything special for me.

    • @NathanielHarari
      @NathanielHarari 4 роки тому

      @@DistroTube Thanks for answering. I was just curious as so many seem to use Emacs for org-mode alone (I love using it myself for all sorts of things).

    • @NathanielHarari
      @NathanielHarari 4 роки тому

      @M T Heh.

  • @GustavoHenrique-xg4ey
    @GustavoHenrique-xg4ey Рік тому

    what are your system font and icon?

  • @dominikheinz2297
    @dominikheinz2297 4 роки тому

    There seems to be an audio delay on this video?

  • @fuseteam
    @fuseteam 4 роки тому +1

    great now i am conflicted :/
    i want that resizing powa but i'm not sure want to bind it to ctrl arrow keys :\

    • @DistroTube
      @DistroTube  4 роки тому +1

      Bind it to whatever. I set it to the arrow keys because Ctrl + hjkl are already binded in my config, and my arrow keys on my Ergo Dox keyboard are in the correct vim order (left, down, up, right) just two rows under the home row. But I understand alot of Vimmers avoid the arrow keys for fear of creating bad habits.

    • @fuseteam
      @fuseteam 4 роки тому

      @@DistroTube yeah i got my ctrl hjkl bound to moving text around or i would've bound it to that.
      alt i keep unbound because it's usefull to exit insert and perform normal mode operations with that.......
      maybe i'll just bind it straight to the arrow keys, no modifiers

  • @netstreamer
    @netstreamer Рік тому

    Why not use tmux to handle splitting? Then you can work outside of vim with multiple programs. I used to do all the splitting in vim and it took me a while to have my muscle memory trained to use tmux keybindings for splitting but it definitely has advantages over using vim as a 'window manager'

  • @SlideRSB
    @SlideRSB 4 роки тому +1

    A terminal inside vim? What kind of sorcery is this?! I just tried it and I'm blown away that I never knew about this. However, I'm a bit confused. When I use :terminal, the terminal doesn't seem to be modal. I can immediately type into the terminal. That also means I can no longer enter commands into vim, nor can I switch to a different pane. The only thing I can do to get back to the document is to close the terminal. What am I missing?

    • @brianfiszman3179
      @brianfiszman3179 4 роки тому

      yep, I use neovim partly because of that
      Here have a screenshot :-D I use a shortcut to toggle and split a terminal in the bottom of my screen
      ibb.co/X2R9sdx
      If you wanna look how check my dotfiles www.github.com/brianfiszman/dotfiles

  • @kalifornia909
    @kalifornia909 4 роки тому

    I have no idea what the difference is with neovim I'm just got comfortable using vim over nano.

  • @waltereikrem
    @waltereikrem 4 роки тому +4

    what happens if you open a terminal inside vim, then open emacs inside that? lol

    • @metastag
      @metastag 3 роки тому +1

      and then you open a terminal inside emacs, from which you open vim

    • @waltereikrem
      @waltereikrem 3 роки тому

      @@metastag now this is asking the right things

  • @1Schueni
    @1Schueni 4 роки тому

    I'm also thinking of publishing my dotfiles, but haven't found a secure and convenient solution yet.
    How do you manage your public dotdfiles? I know you said that you are using a git bare repo, but isn't that a bit dangerous, when you make your dotfiles public? How can you be sure that you don't accidentally publish private information, like plain text password, contact information (in .abook), bookmarks and so on?

    • @peterarbeitsloser7819
      @peterarbeitsloser7819 3 роки тому

      You have to manually add every file you want to commit and no file that wasn't committed will be pushed to the cloud.

  • @frataltay4543
    @frataltay4543 4 роки тому

    Hey DT would you take a look at 6Cord? So recently RoboNuggie made video about this, which led to me going to comments section saying that you'd make a video about this and call it "Discord is bloat. Use 6Cord instead!". I lost the bet as I said but if you make a video about this I'd be 50% right. I'm trusting you dude, you can do it!

  • @jackdavidson5863
    @jackdavidson5863 4 роки тому +5

    You should try modularizing your init.vim:
    ~/.config/nvim/init.vim:
    sources files from ~/.config/nvim/nvim.d/
    Files in ~/.config/nvim/nvim.d are 10-compatibility, 20-plugins, 30-settings, 40-maps and 50-autocmds. You can source all the files in init.vim and you can rank the sources with the following shell script:
    for file in $HOME/.config/nvim/nvim.d/; do
    echo “source $file”
    > the output of that in to init.vim (nameofscript > init.vim) and you are set. MODULAR!

  • @davidgomez79
    @davidgomez79 4 роки тому

    I find using alt+hjkl for navigating splits easier and
    ctrl+hjkl for resizing the splits. and i pretty much use vim as terminal multiplexer
    by remapping alt+\ to open a vertical split terminal alt+shit+\ to a horizontal split terminal
    ctrl+\ to a terminal in a tab. alt+u and alt+i to navigate tabs. alt+f to maximize the split vertically and horizontally
    and alt+= to even out all split sizes. works pretty well as a tmux replacement other than the sessions part.
    oh and u can use autocmd to make terminals not have line numbers. You can be even lazier and remap alt+q to quit
    alt+w to write and use alt+shit+q to execute q! and ctrl-q for qa!

  • @Danielo515
    @Danielo515 4 роки тому

    U back to vim from emacs doom?

  • @SuDaRK
    @SuDaRK 4 роки тому

    for me personally i use dwm.vim plugin

  • @fuseteam
    @fuseteam 4 роки тому +1

    i can do pass any window mode keys to ":W" :^3
    like ":W k L |" will move to the top pane, move that pane to the outmost left en maximize it's width
    or :W t H would do what dt's \th does
    or :W t K would do what dt's \tk does
    heck i can even do :W c to close a pane or :W = to make 'em all equal :^3

  • @CostaKazistov
    @CostaKazistov 4 роки тому

    Audio is out-of-sync (again) - and it's really noticeable in this video. Please check.

  • @Saohesc
    @Saohesc 4 роки тому

    Are your lips moving .5s before you speak?

  • @tenfourproductionsllc
    @tenfourproductionsllc 4 роки тому +1

    Ubuntu Day is only hours away. It's the one event where we get to party once every two years, it's LTE Release season. How many of you are going to celebrate? So get out your best wine, get out your best snacks, put on your COVID-19 mask and party like there's no tomorrow. Headlines from the news will be "Greatest Linux Distro ever!!", "2020 is the year of Linux", "243 reasons to switch from Windows to Ubuntu TODAY!!!, "Never catch a virus again with Ubuntu!". Note - Ubuntu haters will be pouting tomorrow so let's not forget about them.

  • @fuseteam
    @fuseteam 4 роки тому +2

    wait a terminal in vim?
    now i wonder, a terminal in vim ls a terminal in vim mode which is "better" :^3

    • @awabqureshi814
      @awabqureshi814 4 роки тому

      Yeah nvim adds support for a terminal

    • @brianfiszman3179
      @brianfiszman3179 4 роки тому

      @@awabqureshi814 yep, I use neovim partly because of that
      Here have a screenshot :-D I use a shortcut to toggle and split a terminal in the bottom of my screen
      ibb.co/X2R9sdx
      If you wanna look how check my dotfiles www.github.com/brianfiszman/dotfiles

    • @fuseteam
      @fuseteam 4 роки тому

      @@awabqureshi814 ah nvim, tho appearently vim has one too, not sure how it compares tho

    • @fuseteam
      @fuseteam 4 роки тому

      @@brianfiszman3179 cool with a terminal i can't help but think vim becomes much closer to emacs imo

    • @brianfiszman3179
      @brianfiszman3179 4 роки тому

      @@fuseteam to be honest, i've been trying emacs these months and I actually like nvim terminal a lot more than emac's.
      It just feels a lot more natural, less "meta" than ansi-term.
      I mean, have you ever tried to open vim inside ansi-term? it goes all buggy.
      Thats one of the reasons i still not convinced of moving to emacs, the other one is splitting screens, even though im convinced that i can tweak the configuration enough for it to work well with my mindset and my muscle memory.

  • @peacemekka
    @peacemekka 3 роки тому

    Protip: If you have only two splits then Ctrl+w+w will just switch focus between them

  • @holalluis
    @holalluis 4 роки тому +1

    Game changer for me: nnoremap w

    • @DistroTube
      @DistroTube  4 роки тому +1

      So simple. I like it! :D

  • @daniellaerachannel
    @daniellaerachannel 4 роки тому

    I use Vim btw

  • @TitusCornelius
    @TitusCornelius 4 роки тому +1

    Hey DT: thanks for your amazing content! Your videos are a joy to watch and really make my days in this weird and sometimes strenuous time SO much better.
    have you checked out github.com/mawww/kakoune ?
    i haven't come around to actually use it, but it seems pretty damn interesting.. be sure to check out the docu section about unix philosophy/ posix-integration..
    I actually have it on my todo for today to also become a patron. Looking forward to seeing more of you, thanks for being so productive with your content and so professional (not flaming and mixing personal tirades, great studio setup, well-produced videos and -mastered! audio!) in the way you review/present, really means a lot to me!
    All the best, Titus

  • @manvelbeaver520
    @manvelbeaver520 4 роки тому

    Vsplit filename.

  • @MrDadidou
    @MrDadidou 4 роки тому

    the Lip sync is off !

  • @humanexperience75
    @humanexperience75 4 роки тому +1

    Control Dubya

  • @fuseteam
    @fuseteam 4 роки тому +1

    third

  • @BrucesWorldofStuff
    @BrucesWorldofStuff 4 роки тому +1

    Third lol ..

  • @urugulu1656
    @urugulu1656 4 роки тому +1

    20sec.

  • @usrname1105
    @usrname1105 4 роки тому +1

    FiRsT

    • @DistroTube
      @DistroTube  4 роки тому +3

      Your shift key is broken.

    •  4 роки тому +1

      Heheee... [ ;

  • @urugulu1656
    @urugulu1656 4 роки тому

    so you want a terminal? yes
    you want vim mode? yeeess
    you want indication of what more you are in in that terminal? ohhh yes please
    you dont want to go to another stupid shell that does exactly that (looking at you fish)? absolutely.
    then open a terminal in vim lol. i guess someone should be making a configuration that automatically starts a terminal in vim and kills the terminal that contains vim containing a terminal when vim closes. seems like a straight forward enough thing to do.

  • @segadreamcast1583
    @segadreamcast1583 4 роки тому +1

    I am a good user of Vim and Assembly fan, but writing code into Vim is kind of weird)))
    better use simple Notepad

    • @migtrewornan8085
      @migtrewornan8085 4 роки тому +2

      Whatever floats your boat dude but maybe it's worth giving Vim a bit more of a chance. If you wear it for a while you may come to like it.

    • @urugulu1656
      @urugulu1656 4 роки тому

      yeah some of its features are more geared towards higher level languages (yi" for example) but i dont see why assembly should be big deal in vim

  • @_-martin-_
    @_-martin-_ 4 роки тому

    Sigh, don't ever rebind the default editor commands. Then you will never learn and there is no point in teaching others your rebinds either.