vim + tmux - OMG!Code

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Fully expected this to be Chris Hunt's 2013 talk, instead it was something cool I hadn't seen before. OP delivers.

Starts off slow but the Q&A and dotfiles tour at the tail end are pretty juicy.

πŸ‘οΈŽ︎ 6 πŸ‘€οΈŽ︎ u/Cheezmeister πŸ“…οΈŽ︎ Aug 15 2015 πŸ—«︎ replies

If ubiquity is the reason, then why not vim-screen instead?

πŸ‘οΈŽ︎ 3 πŸ‘€οΈŽ︎ u/kirakun πŸ“…οΈŽ︎ Aug 15 2015 πŸ—«︎ replies

I worked with this guy for a brief time. Pretty smart fellow.

πŸ‘οΈŽ︎ 2 πŸ‘€οΈŽ︎ u/mello151 πŸ“…οΈŽ︎ Aug 15 2015 πŸ—«︎ replies

This guy's dotfiles helped me out a lot when I was starting

πŸ‘οΈŽ︎ 1 πŸ‘€οΈŽ︎ u/wanderingscrew πŸ“…οΈŽ︎ Aug 15 2015 πŸ—«︎ replies
Captions
I guess we play there we go hi welcome to my talk on Web Store I'm Nick nisi and today I'm going to talk to you about a great IDE called webstorm it's oh never mind sorry uh I'm a web developer I don't need that crap hi welcome to my talk on vim I'm Nick nisi and I'm here to talk to you about vim and why it's awesome does anyone here use vim like full-time okay you guys are probably better qualified because everyone's always better qualified than me to talk about this but yeah I got into vim probably three years ago and I've been using it full-time ever since and I really like it I've switched from kind of sublime and IntelliJ IntelliJ into vim and haven't looked back so I'm here to tell you that you don't need a full IDE and that you can make your own out of something as awesome as vim and it's also terrible because once you learned them then you'll want to use vim key bindings everywhere and that will get you in trouble but why then it's a highly customizable IDE or editor it runs everywhere I have a vim app on my phone so that I can use vim on my phone and can't I don't even have a file system on my phone but I have them it works with many programming languages and you can add in more with with plugins and it's highly scriptable so let's install vim it's probably already on your machine if you just go type vim unless you're a Windows user but we're not we're Mac users right so we can install it or we can just use it if we install it the best way I think to install it is from homebrew which is a package manager for OSX if you're on OSX that is and you just do brew install Mac them - - override system vim and that will override the terminal bin so that it just shows up first and we'll use that vim instead that way OS X I think Tenten ships with 7.3 but Mac van will give you a fem 7.4 so you get all of the latest goodness and some Mac specific stuff as well but there's also brew install vim if you just want to get them without Mac then I don't actually use the GUI Mac vim on you just use it in the terminal as I'll show so some of the features of vim modal editing that's probably the thing that everybody knows about from vim it's kind of what gives it its distinction you can't just open a file and expect to edit it because you're not in insert mode when you first start out you're in normal mode and you have to switch into a specific mode to actually be able to edit it the modal editing just basically gives you a number of different keyboards so that you have different keys that do different things when they're in different modes so you start off in normal mode that's where you navigate the structure of the file answer delete lines change lines and do creative things to get into insert mode insert modes where you actually edit the file visual mode is like highlighting portions of the file so that you can delete them change them edit them manipulate them in different ways and then e.x mode does anyone use the X mode yeah the X mode is the one that I usually get into by accident and have to figure out how to get out yeah exactly I actually have it disabled in my MRC so that I can't get into it because I don't use it I wish I were cool enough to use it though maybe someday so normal mode is probably the the coolest one to talk about that's where we'll start the first thing is everyone to always tells you when you get into them don't use your arrow keys don't use a mouse your programmers you want to strive to be lazy that's something that a teacher in college always burned into my head was strive to be lazy to try to do things as minimal as possible and I am so lazy that I don't want to move my hand like four inches down to the mouse or two inches down to the arrow keys if I can just stay on the home row I'm happy so I use hjkl left up down right when I first started out I actually had this in my VRC where it disabled the arrow keys so that they would instead echo out stop being stupid and so that kind of forced me it was really frustrating in the beginning now I have them back in but I never use them so it's kind of now I try and use hjkl everywhere else so always be instant messaging with somebody and I'll hit jk jk kind of just playing around in the neck I send that to them and by now everyone network knows you have two teeth you also end messages yes sometimes cyborg you know why HD kale um I was assuming because it's on the home row no it's because the original keyboard that van was developed on or VI was developed on used hjkl as the arrow keys oh okay yeah that makes it like there's a medic key and you use them as heroes gotcha so nice so I just got rid of that excuse there's also like now with you if you follow the vim I don't know blogosphere or whatever everyone's disabling J&K now like that's too inefficient hitting J a bunch of times to go up and down you got to find better ways to do that and I've kind of just naturally stopped using J and K so much I will for you know moving up or down a couple of lines but the one I use the most is probably control Ian's control why I have that that's set up by default to scroll down scroll the the file down a little bit at a time and scroll the file back up a little bit at a time I actually have it set in my mercy to do it three times faster than it normally does so it's like scroll lock yeah it keeps your cursor where it's at but it Scrolls things up until it gets to the top and then it Scrolls keeps the cursor at the top and keeps scrolling ctrl F and control B will scroll down a full page or up a full page so whatever you're seeing on vim it will take that and move it all the way up and then show you everything else that can fit on the page hm and now that will move the cursor to different places in the window itself so it'll move it to the top of the window the middle of the window or the lower part of the window and then there's things like GG there's actually capital G on there but it got cut off on this slide GG if I hit GG it will put me at the top of the file or capital G will put me at the bottom of the file so here's them if you haven't seen it before if I hit GG I went up to line one capital G I went to line 31 H to the top of the file I actually have it not all the way to the top M and L and then ctrl e will actually scroll the window so this is like if I want to see something that's at the bottom of the file I can scroll it up so it's not at the bottom of the window so I can see it better and control Y will go the other way and then ctrl F will go a page at a time and so I've kind of just burn that into my memory of what I do and I actually had to like go practice in a file to be able to write down what all of those were because I just don't even think about it oh hang on I hear there I downloaded this program to actually show her typing so key caster it's open source but it's a really real pain because it you have to manually add it to the assistive devices list okay but that's okay well these days I think you have to do that to anything yeah so that makes you super elite programmer person looks really awesome you're hacking the Gibson you're doing that but that's not what really makes them cool to me I think that vim has the secret sauce that breaks down into three things three or four things I guess however you look at that list I think that the nice nicest pieces of them are text objects and motions the dot command and macros so text objects and motions when you think about that you think about the file is more than just a file with characters in it or words in well words in it I guess but more than just characters that you're manipulating in an editor like you do in other editors so text objects would be like word and sentences and paragraphs and tags tags are only in XML and HTML files and these are something that you can program in to you can add these in plugins add in their own tags for example tags I'm trying to think of a specific one but maybe like a a JavaScript plug-in will actually have like a function text object where you can manipulate a full function at a time and delete the contents of the entire function or other things you can easily add them in on your own or plugins will do that as well but the ones that are kind of billeted in the ones that I use the most are words not so much sentences or paragraphs but tags definitely when I'm editing HTML and then there's motions so actually going back to this oops I'm back to share so if I'm in a file like I'm hitting H to go back to the beginning of the line if I'm you know in here I can say W and that will move me ahead one word at a time to the beginning of the word there's also e to go to the end of the next word and so that's a way of moving and there's other ones as well but those are kind of the main ones I use so when I'm scrolling a file vertically I'll usually use ctrl e air control Y and then when I'm actually scrolling horizontally I'll typically use W and hold that to move as I need to horizontally oops so then there's motions that you can do as well so you can say like hey for all I can say I want to select all of this word or I want to select in these quotes or I want to select until something and then you can also use F and capital F to find forward and backward so I can say I want to do something until the next time I find an S or going right or going left if you use capital F so we can mix those together combine them with commands and then we can do things to them so these are the commands that you can do you can do things like delete this is like cutting because it'll put it on the a default the default register or not registered but clipboard there's change which is the same thing as delete but it after you get done changing something it puts you into insert mode so that you can immediately change it and then there's yank to copy and then V to visually select that will put you into visual mode so we can combine those together to make different motions that we want to do and we can edit our file a lot faster so we can have a command optionally we can have a number before the command so that we can say that we want to do this for the next four like repeat the command four times then a command and then the text object or motion that we want to do so we can do things like di W delete in words so if I go here I'm in grid node right now I have good note highlighted if I do di w I deleted grid node because it deleted inside of that whole word there's C aw so this will change all of the words so if I do CA W it did the same thing but it would also grab the white space on either side of that if there were white space on that but now you can see I don't know if you can tell in the bottom left corner it put me into insert mode all right there and so now I can immediately start changing it J did you have a question yeah so you use C W if I used C W right here I'm on the I of grid node it will change from where I'm at to the end of the word but CAW will change the whole word it doesn't matter where I'm at in the world I know all of the those H's that you could have saved right we're striving to be lazy J so let's change all word then we can do other things like motions we can say we want to yank all of the text inside of the parentheses so going back here I'm inside of the parentheses day I'm just somewhere inside of here I can say I'm actually going to change it to delete because that's a lot more visually noticeable what I'm doing in here but I could say I'll delete inside of the square brackets and I just deleted everything in there that was a di W whoops I'm sorry yeah di bracket there we go thank you but see now if I did that was di W so it left the brackets there if I did D a bracket they deleted the brackets too and I can say like I want to delete until or DT delete until the space then I deleted until the space or I can say DF to delete until the space including the space so yeah we're just striving to be lazy here uh yep that would that would delete the parentheses itself delete everything in the parentheses including the parentheses and then put you into insert mode so that you can then immediately start typing CI yeah yeah so you think about it like inside 4i a is like all delete all including that T like delete until like that's how I that's how I think about it I'm stupid though V a this would visually select all inside of the double quotes including the double quotes so if I'm inside of here this is actually single quotes but all the a that and now I'm visually selecting all of that and now I can do something with that I can get Y to yank that now it's on my keyboard or on my clipboard and I can paste that in I just did command V to paste it in but I could also P to paste it in oops no I'll kind of talk about that kind of some of the things that I have set up to make working with vim easier in a modern OS um so that's that's command motions and text objects and that's really awesome the second piece of the secret sauce is the dot come right there um it lets you repeat whatever the last command was that you did it just repeats it that's it but it's really awesome so like if I am in here and I said this is where using see really comes into play because that will put you little delete and then put you in insert mode so that that's all anything that you change that to and then hit escape that's all single motion so if I had this string and I just wanted to say CI a single quote and then foo and then escape that's a single motion so now I can go down to this other string and hit the dot command hit the dot command oops hit the duck command it just always repeats that last motion that I did so that I can easily change it any time so that's where like I will sometimes spend time I'll do something and then I'll be like wait a minute I could do this in a single command so that I can repeat it and I will actually undo and then redo it in a single command just to see if I can do it kind of s practice and it makes it a lot easier for for working with that and making it making it really useful so there's additional commands that we can do there's DD and YY let's delete or yank the current line so if I Y wide that then I P for pasting I pasted the same exact line it doesn't matter where I'm at on that line it always copies it if I DD it it cuts it and then I can paste it somewhere else yes so oh sorry that should be on here but it's not it's got got cut off on the slide P will paste it below capital P will paste it above the line that I'm currently so all of these commands I mean they start if you start thinking about it like you know delete till DT you know change in CI like I just start singing that while I'm program yes in labor I have to do that to keep from crying sometimes there's the carrot and the dollar sign that moves your cursor to the beginning or the end of the line I capital I in capital a does the same thing but it puts you into insert mode so that's another one that we can do to really help us speed things up so like let's say that we had var foo equals true bar equals Baz backs equals bug I don't know these aren't real things but I'll put quotes around them I repeated that commanded you see that I did that's actually a additional text object that I brought in with a plug in which I'll kind of talk about but I did why siw single quote and it grabbed the word in word and put single quotes around it and then there's another plug-in that makes that special text object repeatable with the dot command so then I can hit dot and now magic so I have all of these write these variables and then all of a sudden your style guide changes and you can't do multiple declares with a single var now you have to do it at the beginning you have to do a var for each one of these so what I could do is I could do capital a to go to the end of the line delete semicolon escape and then here it doesn't matter where I'm at in this line if I just hit the dot command I'm going to go to the end delete one key and insert a semicolon same thing here and then I can go to the beginning of the line capital I delete VAR space escape same thing over here I can delete any time it will go to the beginning of the line and when I say beginning of the line you can see that I'm actually tabbed over it will go to the beginning of the action of the first non whitespace character and work from there so now we saved a whole lot of time doing that in two commands that were repeatable and then repeating at each time I could also with that I could just highlight these and then I can say whoops can I do that yeah I could highlight those and then hit the dot command and do them all at once so I can save some time like that but that was still two commands because I had to go to the end of the line and then the beginning of the line and it's just so much lazy so let me reset that so that I can play with uh too far Vin's history is also phenomenal it will go back forever and I can say I can say earlier two minutes and we'll go to the file two minutes ago cell-free yeah exactly there's a lot more to it I'm okay there we go okay so see my I actually have a plug-in in here called sin tastic that is hooked into my JS hint and J SCS plug-in that that's J's hint which is a linter and J SCS which is JavaScript code style we have these defined code Styles at work everything has to be coded the same way if I don't push up every code that matches the the J's hint and J SCS syntax then it actually cancels my push and I have to go fix it so it's just telling me that here on this line foo is defined but never used so I'm using I'm creating a variable that I'm never using that's against our code style anyway so those are the additional commands so like I said I always think about things try and make them repeatable as much as I can and then I practice it so I'll undo all in do forever and then repeat I'm saving so much time with vim that I have the time to to do this not really but sometimes I'll do that because it does make it more fun and if I have to repeat it a lot then it it really does make a difference but not everything is repeatable with the dot command as we saw in the previous example the two I had to do two different commands and then repeat them to change the beginning of the line and the end of the line but we can do that all in a single command if we want with macros so we can record ourselves doing something and then replay it over again and then do it again so a macro is just a sequence of commands recorded that are recorded to a register and you can pick any register and record it to them and then you can actually save those off to your vim RC and have them loaded up when you load them so that when you access that register it's already loaded with that macro and then you can just immediately repeat it if it's something that you really have to do all the time so to record a macro all you do is hit the Q the Q button you've probably seen this where van will say in the bottom left corner recording and you're like why is it recording what the NSA ah but that's just because you hit Q and then some other key and you're recording into that other key so then you hit Q do all of the things and then you hit Q again to stop recording and then you access that register by using the @ symbol and then whatever the register was so at Q or at whatever will access that so let's record a macro to fix this I'm actually going to so I have I have this line which is different from these two other lines right but this line is I'll just fix that and then this line I'll record myself I'm gonna hit Q W to save into the W register so now that says recording in the bottom left-hand corner now I want to move to the front of the line so I'm going to hit command or a capital I and then I'm going to delete one key or delete one character which is the tab character and then I'm going to spell out var and hit escape then I'm going to hit capital a to go to the end of the line delete that and replace it with a semicolon and then escape and then I'm gonna hit Q again to stop recording and so now I'm done recording now I can hit at w and it did the same thing it just repeated the same thing over and over so I could it will just do the same thing for all of these but I can actually I light I used shift V so capital V to highlight the full line and then JJ to highlight the next two lines and then I could just say : normal to tell it to run a normal mode command at W and it will run that for it'll done that macro for every line that I have highlighted it didn't do anything because it it actually did it replaced this the tab with var on each of those so macros are really cool like that you can repeat commands over and over and over and use them some other cool things that you can do like if I have a data field later that's an array so I have an array of objects let's say this is object 0 this is object and then you know name foo whatever and I want to actually copy this several times what I can do and make it like make test data right I'll say I don't know description I'll do that and I'll do food zero oh there we go okay so I have this here comma at the end and then what I can do actually is I can say I can record a macro that will generate all of this for me without me having to really do anything so one thing that I want I obviously want to have different IDs for every item in my data what I could do is I could start recording well I'll start recording from let's see how would I do this oh yeah so I'm actually going to create an ID field well it doesn't matter I'm just going to call it zero right and then I'm going to mark this line and you can do that with the M key you can say M and then you can assign that to I don't know if they're called registers or or what but I can assign that to a specific location so I'm going to say m'kay so any time that I when I'm whenever I'm in my file anywhere if I hit the tilde K it puts me right back to that spot in the file always so that can be useful another thing that's going to be useful I'll show it in a second but I'm going to start recording right now so I have that save - m'kay then I'm going to save this - mmm this is the current line that I'm on mmm so now I'm going to actually I will record myself doing that so I'm going to hit cue cue to save to the cue register and then I'm going to hit mmm to save that to mark this line then I'm going to go to the K register so that tilde K and I'm going to hit ctrl a and I'm going to increment it to 1 then I'm going to I'm going to why I W to yank in the word then I'm going to move back to my M register which is right here and I'm going to say that I have to go to that zero so I want I don't want to just say move to zero because on line is going to be one and my macro will be broken so I can't do that I have to move over to there so I'm just going to say I want to have space to go to the next white space right there and then I'll just move over and I will hit the are key to replace the single oh wait I'm going to do this totally bad but I'll just do VI WP and I'll replace that with one then I'm going to go to white spaces characters over so I'm going to do two F space oops wait oh yeah so it should have been three of space so I'll do have space again sorry it's all being saved so we'll just repeat everything that I'm doing just totally find even if I in the state exactly if I undo it will do my mistake undo it and then redo it but it'll happen so fast that I'll just look like a magic so it's all good so here I'll do it again VI AWP oh but I paste it in zero because I copied that to my so I'll just do I'll just do this totally bad I'll mark this spot now go back to here yank this go back and then I'll do okay and then I will do I'll get the spaces right this time 1 2 3 so 3 F space over 1 character mark it go back to K yank it go back to M paste it and then I'm done I think yeah I'm overriding it each time I did the paste when you over there actually every key though is a is its own buffer so I can actually save it to a different buffer if I was better at this and not nervous about screwing it up I would just save it to a different buffer and then copy paste from that buffer every time so I didn't fully do this the correct way but I'll just yank this line and paste it and then I will run the macro command so I save that to the queue register so I'll run at queue ah totally screwed up okay and it's because it started from the wrong place I think I have to start from here nope pretend that that worked and it'll be awesome bring up the macro and you can but I you don't remember how to do that off the top of my head but you absolutely can you absolutely can um yeah Coleridge is that yeah I can't see because that stupid thing and it was on cue so there it is yeah so basically all that everything tight yeah yeah you can you can copy it out and then modify it and then save it back to another Ridgid is that how you do it just use it for copying or pasting like I said I've only been using them for three years you have to like so the the registers like I think the double quote is the muties quote zero is the last thing you guys yeah there's a stack of them it goes one through nine so you can go back to the fifth thing that you get and grab that one okay so you can do quote 5p in that little paste of it okay so let's try that you said quote 5p yeah so that's right yeah nice okay but we'll pretend that worked I'm gonna move on yeah you good i suppose in yankee board and then you get back in yeah yeah that's awesome so pretend that you were amazed by that um so those are the three things that I think really make them awesome to work with because if you if you get them down and of course there's a lot that I haven't gotten down yet and I'm sure there's a lot that you haven't gotten down yet - but you you keep learning and you keep editing better and getting lazier and it's great but then the other thing that's cool about them is plugins but other IDs have plugins as well these are some of the plugins that I use that I think are really great for anyone who's going to use vim bundle is a plug-in manager so it will just manage all of your plugins all you have to do is put plug-in space and then the github URL - the github.com part like so if I wanted to put one manage bundle with bundle which you can do you would just have plug-in generic slash bundle because g merrick is the user on github that has it and bundle is the repository on gab that has it it will automatically load that in when I run the plug-in command plug-in install command so that I can manage that and I can manage all of the plugins that I want from there they don't have to be from github they can be from them not order wherever but out-of-the-box that works really easily with github yeah yep the other one maybe not maybe you don't need so much I end up working I do a lot of support so I ended up working with a lot of different files in a lot of different repositories and having a file drawer makes it easier for me to work with that I can see all of all of the files that are there I can easily work with them if I hit I have it mapped to leader K that opens my file drawer this is nerd tree so I can see all of the directories and files in here and I can you know hit enter close these this is actually we're using Mac VIN I'm going to shut off those keys for a minute so you can see it but this is we're using Mac vim comes in to play on the Mac if I hit em I get this list of things that I can do so I have grid is highlighted I can add a new child note here move that so I can rename the file delete the file here reveal and a quick look are the two that Mac via adds in so that I can I can reveal that so I'll hit em r to reveal that in finder it'll open finder and show me that file and then there's also em oops focus em Q will quick look that so I'll get the quick look view of that file if I need to I hardly ever use this but I do use mr to reveal in finder all the time especially when I have to like work with images or something it just makes it easier to navigate out of that but this is here I can add a new file ma foo Jas now I have food I Jace and I can open it right over here so making it makes working with that a lot easier ctrl P is a fuzzy file finder this is really necessary to quickly navigate the file so if I wanted to open a test class I could just go down a couple or I could do map to leader T it pops up and gives me a list of all of the files and now I can just do a fuzzy find so I can say test class is and I didn't have to type all of it out but it found it found everything that matches from that and then I can immediately open it from there it also keeps track of every file that you have opened in your register so I have that mapped to leader R and these are all of the files I have loops although the files I have open and registers and I can filter that list with just by typing as well so I can open toolbar back up or whatever mmm fugitive is a git tool this is fantastic it does things let me move to a repository that has get on it or is maintained by get like this one this is dojo I can do things like : G blame and I can see who edited every single file or every single line in this file and if I want to get more information like maybe this is the bug I'm curious about I can hit o and it will show me the diff and the commit message from that commit for that line and I can edit it I can view it right there I can also navigate history from within here I can get the log of this file and it will load every file or every version of this file in a buffer so that then I can do I can do square bracket Q I think to go to the second version the third version back keep going back and back and back and I can look at each version of the file and then when I want to go back to the head that I'm on just G edit goes right back there's plugins to do that this one won't if I change things if I went in and deleted this that code and saved it then I can do G diff and because my editor is so big it's putting it top to bottom which isn't really helpful let me make my font a little bit smaller very small I guess and then do G diff again now its side to side and you can see what's I deleted these lines right you can also you can also fix merges merge conflicts and everything resolve conflicts that's what I was trying to say from there makes it a lot easier and you can do things like I changed this file so now I can do G right I have these maps two keys as well but I'm just typing out what they they say that did a get add essentially and then I could do a G commit and now it opens up them for editing the commit message the nice thing about this having doing the commit messages in the same instance of them that I'm running is everything that you type in vim or every file that you open in vim goes into VIMS autocomplete so that you can use that to autocomplete your commit messages as you need so I can say like fixed what file is this declare de then I can just autocomplete it because it's all in the same one and then I you know WQ save it and it just closes that I can also do like a get status so it'll show me all the files that have changed nothing has changed but let me go in and delete some more and then this now it shows me that this is not staged for commit but I have edited it now I can hit minus and that will stage it for commit and it - again - unstaged that file so I can work with this I can work with this without ever having to leave them if I don't want to which is pretty nice that's called fugitive give it the get in there oh yeah yeah it's really awesome and then the other one is fantastic and we kind of showed that in here how you do a lot of JavaScript development but santΓ‘sticos if I save this file actually do I have it enabled there we go so now it's telling me that's fantastic that popped up on the left there and then when I mouse over that it says illegal break statement in here so it's complaining about that but this lets me kind of stay on top of all of my misspellings and typos as editing it just checks the file each time on save so that's cool and it works with out-of-the-box it works with several different things but you can also configure it in your MRC telling it what you want to actually run on each file save or not run so it's very configurable so those are the kind of the main plugins that I use I have like 50 different plugins probably but those are the main ones that I kind of boiled it down to and yeah IDE still do a lot more but for members we're a lot cooler anyway so we can make we can customize them to tailor it to the exact needs that we have my needs aren't going to be the same as any of yours probably I do a lot of JavaScript development so I have a lot of JavaScript specific plugins in there if you do a lot of you know Swift or objective-c development or Java or C++ whatever you might have several different plugins that look completely different to mine so you can really configure it to the way that you need but we can still do more with them so this is how I typically run vim with T MUX is anyone use T MUX yeah okay awesome yeah see I love tea mugs so you can get T MUX again from homebrew if you're on a Mac brew install T MUX or from whatever package manager that you may have you know what it is is it's a terminal multiplexer you can view and control multiple consoles at once separate them out into windows each window can have multiple panes you can have several different sessions and you can pre configure your environments excuse me pre configure your environments for whatever you need you can start a new session just by doing T MUX new session - s and whatever the session name is and then work with it from there so let me actually disconnect from this session I actually have this mapped to a new command or to a command a shell script that I wrote that will automatically I hit TM it lists out the command of the sessions that I currently have or I can hit three to start a new session in this case so I'll start a new session and I'll call oMG and so now in the bottom-left corner there you can see it says oMG that's the session name and then I have a window here that's called zsh because that's the command that I ran if I open them in here it changes that to vim but I that's not very helpful so I typically if I list out the sessions that I have I have my work session I have this pasta session which is just a random name I thought of for the session name if I go in there you see I down here I have dot files and talk and dojo and automaton and vim in vim the first four are ones that I custom named so if I go to my dot files I can actually either mapped I'm not sure if it's a custom mapping or if it just works I have it mapped to control a comma and I can change the name so I can change it to J is asking a question and now that window is named J is asking a question J did you have a question those are all local they're all local windows that's just each one of those is running Z shell locally for that I can SSH in from any of those and do whatever I need to from there and then inside of that SSH I could nest a team accession if I want but you have to have there there is a way to connect to a remote like directly without having to do SSH you could you could program these so that you have like a specific environment that comes up every time you run and you could have the first command that it runs be an SSH into whatever box and assuming you have your key setup actually program yeah um but I have a I don't always do it but I do have a file that I have this is my dot files and inside of T MUX I have a dev team X comp and in here this runs it just will source the file it'll source my original team XCOM so basically when I connect to team axe I have to pass it a command to tell it this is actually my configuration file to run so then from this file I source the original file so everything gets loaded as normal then I tell it I want to create a new session called dev with a window called IDE I'm going to split that window vertically and it's going to have a I think that's a height of ten inside of the dev window huh ten percent yeah and then I'm going to select that top pane and inside of there I'm going to split it I'm sorry I'm going to select the bottom pane and then I'm going to split it horizontally and then I'm going to create a new window that I'm going to call shell and select that window and then I'm going to select the current pain and that's where it's going to leave me so when I run this it's going to leave me in there okay can you run our commands outside oh yeah yeah you can just say send keys and then it will just start typing like you can say send keys SSH whatever and it will just type that in CR for carriage return that's very useful yeah I don't know what that is no I think it's just lying yeah yeah yeah it's not waiting for response sorry another interesting probably knew that that idea is so fine if I'm managing like multiple servers yep I'll SSH any server and then I'll synchronize all the pains so that everything I type into one get sense yeah I was going to talk about that yeah that's a good point I do that a lot um yeah the there is also so this is just running this is basically running shell commands here it's just changing my configuration file to this file and then running the original config and then running all these commands there's actually a ruby gem called team oximeter that lets you configure your environments in y amal if you are into that sort of thing and then you can manage it all through mo files yeah I was trying a steam box theater but let me do something this sophisticated yeah yeah I think this is what I really want oh yeah but essentially I'm already in a team accession so I won't run it but essentially what that's doing is it's creating a new window so I'll create a new window yeah let me okay let me disconnect here yeah how do you call that so let me make sure that it's actually in here because it's this is my home directory yeah Deb dotty max calm so I think it's team Oaks forgot how to run it's been a while since I've run it is it - see teemo's okay so you actually have to point it - you don't have to mines that uploaded oh I accidentally just closed the shell but that's okay because I'm I'm running T MUX so yeah I just reattach and I didn't lose anything so going back into it I can just hit ta to reattach the last session I was in everything's back to where I was no problem I totally forgot the commands to run that that I should have remembered to look at that it's not that see it's Oh team Oakes F dot dev team XCOM totally didn't I'll look at that at the end sorry if there's a way so if you start a an empty debug session yeah is it a way to record what you're doing with the command keys into those battements I don't know if they'd easier just to set up the one do you want absolutely absolutely there is a way there I haven't researched it enough yet I haven't had enough time but there's a whole plugin like similar to bundle there's a plug-in system 40 bucks and there is one that will actually like like you saw how I accidentally closed I term and I just reattach to it well if I shut down my system that session is gone but there's actually a way to save that session between restarts and you can just bring it back up so you can always have that set I yes I haven't looked into it a whole lot but I have seen that I'm pretty sure but anyway what that was trying to do was it was trying to create a vertical split like that and it was putting it at like 10% so I can't get there with my commands but essentially creating that and then horizontally splitting this and so it had each of these different splits in there that we could use so now I can see all of these navigate this is typically how I work where I have vim at the top and then I'll have a terminal down here if I need to run a command or see the output of something right here so can connect just like that the dot T moocs Kampf in your home directory that's your team X configuration there's lots that you can do if you look mighty MUX looks very different from what it normally would look like mine doesn't have the ugly green bar wanted mine to look a little prettier than the default so it it lays everything out nice I have a whole theme set up for it I even have I customized what's in my my bar down here so you can see I have the name of the session all of the windows I have Taylor Swift always and then I have the date and the name of the Machine I'm on which is routing music the music it is I actually tell it let me just open up the Tmax config right here go down to the actually it's in my theme file I'm pretty sure yeah so in here I just have you know you just pass the the yeah it shows that out and it will execute that I think I have it executing every 5 seconds it just executes s' the shell script and asks Spotify or iTunes I have the RTA one I'm not using the RT one right now let Spotify or iTunes it asks them hey what music is playing right now and one of them or if they're both open they'll both come back and I'll just up double in there but I typically never have both open so have you tried playing around with your JavaScript support not yet yeah that's that's only list to play around with though why you would have not yet these scripts are really simple there you go count in pretty much a if they have the the built-in Apple script support so this this one right yeah yeah this is the Apple script it just says if application Spotify is running then tell application Spotify to set the variables so the name the artist the album and then return the little music icon with the name and the artists - the artist and that's all it does but you could buy Corolla somewhere yeah yep and it doesn't have to be Apple script I'm just using that for for this but be way easier if you didn't have to write this way I guess previously only apples critics could really talk to you out yes but in your somebody JavaScript can too which is awesome yeah just could never bring myself to wear an apple script so there's a lot you can do with team ox and that's all in your team ox config the one that I think is the most important probably is this right here well is by default the prefix command 40 MUX is control B which is kind of annoying because I'm lazy and control be like it's so far away and I have to like actually look at the keyboard to do that those compatibility with screen yeah because well screen is control a yep yep uh but I I unbind that and I actually set it to control a and then in my OS settings I go into the modifier keys settings and I change caps lock to control because I never want caps lock enabled ever yeah oh that's a good idea yeah so now if you look at your keyboard caps lock is now control so control a it's just baboom right next to each other yeah exactly control left bracket is escape yeah yeah there's actually a program called Kira map for MacBook and it will let you do more advanced modifier key changes so I can say can caps lock is control when I press it with something else otherwise if I press it by itself it's escape amazing if you look at the the copy and paste for commands 14 box there left bracket right bracket so they kind of match to the escape yep so there's a lot that T MUX can do like like you were saying we can synchronize panes which is really awesome I've seen I've seen people you know have a bunch of different terminal windows open and then they're trying to do things all at once and there's a program that will do it for you but you can also like if I create a bunch of different panes and you know I can type in here echo hello and it just runs in there I have this map to prefix Y so I just say prefix Y and now everything is synced so now I can say echo hello and you can see it's typing into every one of them and so I could be SSH into several different boxes and running the same commands from one if you're too lazy to have written a script to do it yeah yeah exactly or if it's not worth writing stuff do it yeah oh yeah if you can write a script to do it strive to be lazy yeah actually people use this for a pair program yeah you can connect to someone else team up session and share it yep this is great actually I wasn't sure how this set up was going to be and whether or not I would just mirror my display or if I would actually have like my display down here and then another the second display which is up there what I've done for presentations before is if I you know put this over here and then I open a new window I would just have a terminal window on each one and I would connect oops connect to the same session I connected to the wrong one oops which one is it I'm currently connected to pasta so - now I'm connected to the same one and now I could that way I could look down here I didn't have to like try and look behind me and type commands I could look at the screen and it's just mimicking everything I do over here so you can use this use this you can definitely use it for pair programming I've seen tutorials that help you set up like a user like a script that will generate a user that only has access to this file or this system and can only attach to this session and then it deletes itself afterwards and it does that all through I think in grok so that you have a you can expose yourself out remotely and stuff but there's also a fork of T MUX called teammate which does all of that for you and lets you remotely connect with someone else to do pair programming like this yes yeah the yeah absolutely yep you make it reading sir wait I don't know if you can make a read only just blindly agree well yeah that that's actually true because them would be so specialized I'll tell you probably the number one key binding that I have like don't : WQ is that's like three characters you have to type the oh four you have to hold shift : w well that's a lot yeah I want to say you can do that team-ups I don't know how I'm pretty sure I read about that before I think I have to but I don't there's like an obvious features yeah so you can synchronize pains you can create splits on the fly I actually have Team X set up so that I do control do prefix which is control a so prefix HJ k RL I'm sorry that's to move between them so I do control prefix H I'm sorry prefix J to move down prefix H to move left prefix k to move up if I want to create a split its prefix pipe to create a vertical split and prefix - to create a horizontal split so it's just kind of logical you really have seen yeah I remapped okay yes percent in quote yeah I also have them set up to do that as well so I have them set up so that it's I can split them in a very same way I can just say control HJ k RL so control L will create a right split control H will create a lap or move to the left split but if there's not another split to the left it'll just create another one and so I can just keep keep creating splits all over the place if I want to look at file like a lot of different files I'll have I won't put them all into individual den sessions I'll have them all on the same bin yep so typically when I'm working at home on my Thunderbolt monitor I will have it split like this and I will usually have six different files open that I'm looking at which is totally not productive but it actually it's not too bad on a big monitor but that's typically how I'll have it also another great key this is by default in vim or ohms or ent MUX ctrl-a the prefix Z that will whatever whatever split you're in it will make it fullscreen and then Z again to bring them back so if I want to see everything then I can see it bring them back as I need them and it keeps everything up can you take like a pain and promote it to a full window uh yes Terra offers I think so yeah yep I've done that before I knew about control-z I had a whole script that I looked at from a tutorial that did that and then it tried to bring it back in because you can like take these pains promote them to Windows and then move them back and that's what it was trying to do but high prefix Z is that not the default in my lying to you yeah um it's not control Z well like is it control AZ or control control beatific see works for me yeah so yeah you can do that so tea notes in vim are really awesome there's also a plug-in called vinick's which allows you to interact with team x from vim and so you can do things like map or you can call you can say vinick's run command from within vim and execute a command in of MX or in a tea mug split and then and then see the output immediately so like I have this repo here that I'll delete this split at the bottom and I'll do I'll just map it to a so I'll say n map I want to map leader Z to call Linux run command sorry if that's small there we go the next run command grunt test so I want to run the tests for this and then I have to hit enter so I'll map that now all I have to do is hit leader Z leader is comma for me so comma Z and it automatically created the split for me and it ran grunt test down there which compiled all of my typescript and executed the tests now that that split is open if I hit leader Z again it will just use the same split it's not going to create a new split each time but now I can have that mapped to like do that every time I save the file and automatically see that I never have to think about it the the files or the tests will just run below me and if an error you know it'll turn red and I'll see it immediately and then I can go investigate it so it's a lot faster than than having to manually because I'm lazy I don't want to hit prefix a or H prefix J to go down and then grunt to this and run that and then prefix K to go back up that's so many keys and I'm so lazy so I don't want to do that I can just map it and you can do those maps on the fly or you can save those into your MRC or a local VAR see I have that set up so I can have them RC local in any file in any directory and it will source those all the way back up so there's a lot you can do I like them and I think that you will too but if you even if you're not using them as your editor learn whatever editor that you are using very well so that you can be as productive probably not as productive and not as cool for sure but you know you can you can be something I guess the other thing I was going to talk about is is your dot files like your VMRC your team Lux config all of that there they're really awesome this is how you make them and team ox and you make your own environment that works well for you and then and the software that you're writing and there's a lot of dot files out there on github look at them steal things from them but don't just flat-out copy them don't use things like janus or other things that are Janice is a default vents configuration that's default for and it works well for somebody who created it but does it work well for you is it going to add a whole bunch of mappings that you're never going to use is it just going to clog everything up plus you can never possibly remember exactly if they contain exactly you have to put them in one piece at a time and order them yeah and every once in a while I've done it once I think since I started using them full time I declared vim bankruptcy deleted my MRC and then I just started adding things back in as I needed that and though it is like I go through like like what the heck does leader day do I never use that oh it does that yeah so never copy them directly steal things and get ideas and then share them so that other people can see see them get it share so yeah share your your dot files steal ideas from others there is mine Nick nisi slash dot files all of my them T MUX and zsh configs are on there along with other things github yeah sorry also my get configuration all of that cuz I have a lot of to get tricks and how do you manage keeping like API credentials and stuff like that out of your bail files yes uh that's a good question I won't bring it up because I'm recording this but I actually have so I was let me just finish this real quick keep practicing I I put all these slides and everything up here at vim workshop so check it out and then like I wasn't going to end here I was going to actually go through a little bit of my dot files to kind of give examples so I'm going to flip s-- I'm going to rename this from J's asking a question back to dot buttons and so these are my duct files what I actually do is I use Z shell and in my Z shrc I actually have set up a where is it well if a bid directory exists in my oh no wait yeah if a local RC exists source it so I can put everything in local RC and that's I'm not actually saving it to my dot files it's just on that machine and then if I move it I have to remember to yeah so you just set up like variables and stuff yeah private stuff in there yep like I have all of my my keys and everything in that file and then it just gets sourced and it's not see I have that set up in here the other thing is like I have my Dell file setup all weird I have actually an install script that goes through and everything with a dot symlink it creates a symlink in the home directory and puts a dot in front of it yeah it makes it really nice for for keeping everything as a script you wrote I copied it from somebody Zac home and I think anyway that's not a bad approach yeah yeah it works really well so that's my Z shell I was going to bring up my vim RC a little bit where's Finn so here's my vim RC and as you can see it's 444 lines so I've got quite a bit in there but I've got it kind of set up split off pretty well so I've got all of my general configs I've actually got my whole list of plugins in another file just to manage it so let me open that I see so you UK Leah's common misspellings yeah nice so plugins that vim here's all of my plugins this line this file is 77 lines long I turn plugins on and off as I need them if they're commented out in here the plugins aren't loaded at all and then I can just experiment that's why I've been bundle is really great because you can experiment and I can tell it to install just by doing : plug-in oops I'm not going to run it cuz it'll take forever but I could do plug-in all run plug it install it will just go through and look for anything that I don't have installed and install it and done if I do plug-in update it'll go and update to the latest of each of those but the main plugins that I have I have them kind of split off it's kind of messy in here but instead of what you get cloning all these things into your home directory yeah you just do that yep and so they're inside of this bundle directory and they're all cloned right within there and then bundle just manages these are all get ignored in my duct files so they're not just get cloned your dot files and then run your script yeah I actually have bundle installed as a sub-module and another sub module in there so you update add the sub module or you know update the sub modules then you just do open vim : plug and install and or you can do VIN space plus plug and install and it will execute plug-in install immediately when it opens and install all of those I experimented a lot I don't know if I like sub modules all that much so I'm yeah I need to look into sub trees more yeah so I have all of that set up my install script does a whole bunch of things if I actually look at that it does it updates the sub modules then it sources link which I don't remember with that oh that does the sim linking then if I'm running OS X then it's going to install homebrew automatically brew everything that I want in here so I'm going to get run the brew dot Sh script which installs at get and Mac them and all of those also you can pretty much just scanned up your whole Devon barley yeah I I just got this machine and well I I had a MacBook Air and over the holidays I reinstall I did a clean install of Yosemite and then two weeks later I got this MacBook Pro and it took me 20 minutes to get everything set a cup on both of them like really simple I got mine set up so that I have a public vagrant script oh nice so I just yep that's really nice it sets up the entire machine yeah however you do it it's worth it to get this setup because if this machine fails I can go to another machine yeah I know people have been these like popular boxing or somebody that sort of things that I've never seen BIM used to set all that stuff up before yeah so it sets all of that up and then um anyway going back the main things that I wanted to show in here were just not to keep this going because I could talk for hours on this file alone I have this set up so that my backup directory like it doesn't create the swap files in line with all the other files it puts it into a vim temp directory in my home directory and they're there if I need it I'll usually I don't ever need them and I just go in and delete them whenever three but yeah there's that the other thing is I set clipboard to the unnamed clipboard so that whenever I yank something it puts it on to the OS X clipboard and then I can just ctrl V into another app so I can I can go here and YY and then I can go over and open up Adam or something someday yeah arrow keys ctrl V and I can paste whatever is right into there so so unnamed is the system yeah okay yeah right I mean is probably my use probably and actually to run it in T MUX there's actually more things that you have to do because T MUX totally devours all of that but there is actually if I go to my team X config the first thing that I do is I execute a default command which is this reattach to user name space command which is something that I installed from homebrew you install that and then it brings the clipboard sanity back to T monks this is something that you need only if you're on OS X so I actually have to update this script because I have a Linux box - and this just fails every time I try and connect because I hardly ever use it but if I need to I did actually have to execute a different script that checks to see if I'm on OS X and if I am or check to see if reattach to username so ice exists and then run it otherwise just open up a new Z shell session so I have that set up that makes it really nice now I can do things like I can copy things out of here and I can go in and paste everything I don't know what I did and I can't I can paste everything into any application and same thing from from within from within T MUX itself I can do control a escape and now I can navigate this with hjkl and I can shift V or V 2 T MUX highlight so the orange is the team ox highlighting then I can why to yank that and I can go over into this is actually my slide deck so hopefully and I pasted all of that in there oh wait did I know I didn't I may have I may have screwed that up what I typically do is I hold alt and then I highlight with the mouse I know I use the mouse the worst then pasted in there I also have mouse do I do have the mouse set up so in in my team XCOM and in my vim our see I have a mouse turned on and that's just so when I'm moving from one screen like from one application over to here I can just click into the window that I want to be in and if I mean if I have multiple of them splits I can click into the split that I want to be in so yeah that's that otherwise I never use it when I'm actually working in it it's just when I initially switch into it um trying to think if there was anything else the other thing is the Marcie so I can have everything set off oh I have this set up so that I can I have my background and my color scheme actually controlled through my Z shell so it just looks for exported Global's in there and I have all of that setup through I'm currently using this base 16 which has a ton of different themes and a dark and light for every one of them yeah it's great and so I can I actually have aliased you know I have dark and light so I can just say if I could spell light and it will just immediately change everything and if I go back into vim ah if I go into a new room session then it's light and then I can switch it back to dark quickly too so that's great if I'm giving presentations and I don't have a nice projector like this and I have to switch to light then works really well for that and then I can change the the theme as well and so I handle all of that the themes are synced so there is a I term theme or actually a shell theme which is all of these files for like brewery dark is this file this is the shell theme and then there is a corresponding VIN color scheme that matches this so that the shell and them always have the same theme I can figure it in one place and it works really well and I think that's it unless anyone has any questions and or anything so one thing with tea box and this is really bug you live this was really valuable this time I used it I if you're using item two and OS 10 and tea box you can actually have item to connect to a tee box session and all the tabs and tea muscles are intense and I can't do and it was indicated that over SSH except the last time I used it was really buggy and crashed yeah so you might as well just use tea box directly but it was just kind of one of those things from the middle rounded for days right yeah last time I looked at that you actually had to have a different version of team acts like a alpha version or something yeah and I I don't want the window crew yeah oh my nice pretty pink split borders in there that's all all configure there's actually like I said there's a plug-in system for T MUX and there's themes for T MUX and everything so you can get you can see I have the power line theme for vim here this is actually airline but it's you know it's got these weird characters and everything you can get the same thing for your your team ox bar down here but yeah cool thank you
Info
Channel: Nick Nisi
Views: 647,108
Rating: 4.9250364 out of 5
Keywords: Tmux, Vim (Software), Software (Industry)
Id: 5r6yzFEXajQ
Channel Id: undefined
Length: 77min 21sec (4641 seconds)
Published: Thu Feb 26 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.