Linux For Programmers #9 - Linux Text Editors (Nano, Vim & Emacs)

Tech With Tim · Beginner ·🛠️ AI Tools & Apps ·5y ago

Key Takeaways

This video tutorial covers the basics of Linux text editors, specifically Nano, Vim, and Emacs, and demonstrates how to use them for editing and managing files in a Linux environment.

Full Transcript

hello everybody and welcome to another video in this linux for programmers tutorial series in this video we're going to be talking about some common linux text editors and just giving a really quick guide on how to actually use them now the two editors in particular i'm going to be talking about are nano and vim these come by default with your linux distribution or with ubuntu if you're using this distribution then i will very quickly at the end of the video show you emacs in case you care to use that one i want to preface this by saying this is not going to be a ton of depth or detail on these editors there is a lot to learn about these and literally hundreds of shortcuts that you could know or that you could use so i'm just going to give you kind of the basics and enough to get by in these editors anyways let's dive in after a quick word from lenode which is a sponsor of this video and this series lenote is one of the best platforms to use when hosting a service app domain anything in the cloud anything that runs on linux it will run on lenode lenode is really a great platform for developers they have a ton of integration with popular databases with kubernetes with docker and there's a ton of other things that you're going to be using quite commonly as a developer so that said get 100 in free credit towards lenode by clicking the link in the description and signing up with a new account another reminder to make sure that you're signed up for the last five videos in this series there will be another link in the description you can sign up on this platform register with your name and your email and you will get notified when these videos are up and you will have access to them before everybody else so that said let's dive in [Music] so the first editor i'm going to show you how to use is personally my favorite in my preference when i'm using a linux machine and that's simply because this one is just really simple it's super easy and a lot of times all i need to do is copy or paste something or just write a few lines and i find nano is the easiest to do that in anyways to access nana you simply type nano we've seen this a few times before you also can type the file name afterwards so if the file currently exists so let's just say you know test.txt if this file currently existed in the directory that we were in then it would open this file if this file didn't exist then it would create this file so if i say nano test.txt we don't have a test.txt it's actually creating this file for us so now what i can do is i can start writing some stuff in this file so as you've seen we can just kind of type we navigate using the arrow keys here and then a bunch of the common commands for nano are listed down below so the ones that you really need to know first of all is paste cut and copy as well as write out and save so if you hit control s this will save the current file but if you want to save as so you want to save this as a different file name then you would do control o so whenever you see this little hat this usually just represents control so i'm going to say control o and now notice it's going to ask me what file name that i want to write this out to so you can think of control o or write out as kind of like a save as so here what i could do is you know change the file name or change the extension extension and then write it out of course if i want to cancel i can do control c now to look at all of the options and all the keyboard shortcuts you can do control g and when you do this you can see that there is a ton of things and again you got to navigate here with the arrow keys to go through this but you can display the help text close the current buffer or exit from nano that's control x write the current buffer when it says buffer it just means whatever is in the file here i insert another file into the current buffer there's a ton of stuff that you can do and again i don't really want to go through a ton of this stuff but this is kind of the basics now i'm going to show you how you can actually copy and paste text because this is probably the most common thing you're going to do if you're using an editor like nano so to copy something in nano you actually have to figure out how to select it now this is in my opinion harder to do it not very intuitive whatsoever but to select some text that you would like to copy you're going to use your cursor as well as a keyboard shortcut so what you need to do is you need to mark a position this is where you're going to start copying from and then you will use the cursor to highlight an amount of text so to mark the position you're going to use the uh the following shortcuts so control and then the hat or control and the number six now notice that there's a little hacked where 6 is if you were to press shift that's what it is in nano it will say control plus hat but anyways you get the idea so control plus 6 or control plus hat then after that you can use your cursor to select text so you can see that this is kind of highlighting and what will happen is that when you decide to cut or copy or do whatever you're doing with the selected portion it's going to go up to and not including the cursor so right now this will include the entire string hello but if i move my cursor over the o it's only going to include the first four letters same thing here if i did it here would only include the first three letters so just make sure your cursor is placed after what you want to select or what you want to copy because obviously that's just how it works so now when you want to copy something and also notice down here it's saying mark set so we're marking a portion when you want to actually copy something you use the following command it's actually alt and then 6 again or alt and then hat now it's not going to do anything other than remove the current mark when you do that but this will now be copied to your clipboard at least in nano so now if i want to paste this text i can do control and then u and it's going to paste it out and of course i can paste it as many times as i want now there's a ton of other shortcuts as well again i'm not going to go through all of them but another common one is the cut command so if you wanted to cut some text out in fact let's just cut these three hellos right here you're going to place your mark so you're going to do control and then six or control and then hat you're going to select what it is that you want so so let's select all this and then you're going to do control k so ctrl k and notice that cuts all of the text i can move down here and then i can paste all of that in with ctrl u so that is cut copy and paste on how you write out and save a file now of course there's some more things but that's kind of all i want to show you for nano just really wanted to give you the fundamentals so you understand how it works now to exit from nano you can first save so ctrl s or write out and then do control x so control x will bring you out here and now we'll start talking about bim now before we continue i need to quickly thank the other sponsor of this video which is algo expert algo expert is one of the best platforms to use when preparing for your software engineering coding interviews and i happen to be an instructor on the algo expert platform at this point in time i've created over 15 coding interview questions on algo expert if you want to check them out you should go to the link in the description and use the code tech with tim for a discount on the platform so to access vim on your computer what you're going to type is vi or on your linux machine sorry vi stands for vim works very similarly to nano if you want to open vim and create a new file with a certain name you would say vim and then let's just do test2.txt and now this is opening a new file or creating a new file called test2.txt and you can start writing stuff in it now the most confusing thing about vim is that right now i actually can't type anything in this file i'm in this file right and if i actually start just mashing keys on my keyboard nothing's happening why isn't anything happening well vim is something that a lot of people really like and something that a lot of people really hate i'm kind of somewhere in between i'm not a huge vim fan but i don't mind it anyways vim has two modes so vim has an insert mode and it has a command mode so when you're in insert mode you can actually modify the file right and when you're in command mode you're typing specific commands that will they could modify the file as well but they're not you're not writing them into the file directly you'll see what i mean in a second but anyways to get into insert mode in vim you type i so notice when i hit i on my keyboard it says insert at the bottom of my screen now to get from insert mode back to command mode you hit escape so now i'm back in command mode and if i start typing well you know nothing's showing up but if i go i i'm back in insert mode and now you see i can start typing stuff in this file now there is a ton of stuff to go through with vim more than nano so again we're not going to go through all of it but i'll just talk about some basic things so first of all let me show you how to quit vim because this is the most frustrating thing ever they do not make it very easy or intuitive whatsoever you need to go into command mode so if you want to escape this you you hit escape and then what you do to quit is the following if you would like to save your changes and quit you type colon notice that's showing up at the bottom of my screen then w q and then you hit enter now what this will do is save the current file and quit so if i hit this it's going to save test2 now if i open this back up hello is still in here so now we are currently in command mode that's the default mode you go into if i want to quit but i do not want to save then what i do is colon cue exclamation point again not intuitive whatsoever but this will quit bim without saving the file when you do that it's going to exit now obviously we didn't make any changes so we still have the original file now let's talk about a few other things you can do so first of all to navigate vim there's a ton of shortcuts like so many different things you can do to go to the end of the line go to the first word remove the first word delete the first word all kinds of crazy stuff and if you know how to use vim you can actually be really productive with just the keyboard and no mouse whatsoever anyways that's definitely not me but let's go through how to copy paste and highlight so if you want to start highlighting something in vim you go into command mode and you hit v now you're in visual mode and notice that you can start highlighting things in the file so this is called visual mode in visual mode there's a few other things you can do but anyways here we are i've highlighted the first word here hello now what you can do when you're highlighting is well you can copy and you can paste so if i want to copy this i can hit y and now it says three lines yanked and what that means is i have copied this text like yanking is the same thing as copying in vim so now i can navigate into the file where i want to paste this and while i'm in command mode i can hit p when i do that it's going to paste this wherever i have my cursor in the file so that's how you copy paste and highlight in vim now just to show you some of the cool things you can do with vim i will show you how to delete one word or one line at a time so let's go into insert mode and let's type some more stuff so we'll just go hello hello hello you guys can see how creative i am with my uh my words here all right so sorry something messed up and i had to restart vim anyways we're back um i'm just going to show you a few other cool commands you can use in vim they're not necessarily super useful but just showing you kind of what you can do in vim and the type of commands that they do have so first of all let's highlight some more stuff so let me highlight this word here uh so let's go in v mode now while i'm in visual mode if i want to delete the highlighted text i hit d on the keyboard and notice all that's gone i have deleted it now there's a few other things that we can do we can undo with the u command so when i type u that is how you undo there's another one you can redo so control plus r actually redo redoes whatever change you had i can now undo that again i know this is a ton of things not expecting you to remember them just showing you the kind of shortcuts they have now what else we can do is we can move forward one word we can remove one word uh we can paste after the cursor there's just so much but i will show you how we can move forward one word because that one is somewhat useful i guess if you want to navigate like word by word you can use w so w will skip forward one word again when you're in command mode and then to skip back one word you hit b now again i don't know why they came up with these um but you know you have b and you have w and that's how you can kind of navigate one word at a time through the file i don't know why that's super useful but there you go now if you wanted to move to the beginning of the line what you do is you hit zero this will move you to the beginning of the line now if you want to move to the end of the line what you do is you hold shift and then you press four because you're trying to access the dollar sign so this will move you to the end of whatever line you're currently on and again to go back to the beginning you hit zero now i can show you a ton more i think i'm going to stop it there just because there's not really much more value in showing you these you're going to have to look them up anyways but now let's quit so we'll do colon wq exclamation point to save there we go we closed vim and that was kind of my quick run through on vim so now that we've gone through vim and we've gone through nano i'm going to show you emacs a lot of people like emacs i don't really use emacs but i'll just show you how to install it on the machine so to do this you can do sudo sorry you actually don't need pseudo if you're signing as the root user but if you're not signed in as the root user you need sudo now i don't know if i've discussed sudo but sudo stands for super user do and when you are in the sudoers group or you are a part of the sudo group you have access to the sudo command so if you don't have permission to do something you just preface the command with sudo and that means super user do and then you're able to actually do that command so i probably should have mentioned that i apologize that it's this late in the series that i've talked about pseudo because you use that all the time but again that stands for super user do and it will grant you permission to do something assuming you are in the pseudo group and we talked about that in groups and users and all that okay so now we will go to emacs so to install emacs you can do apt hyphen get install emacs now if you're not the root user you're going to have to put sudo before that and then this will run and install emacs now i already have emacs installed here but this will probably prompt you with a yes or no answer like would you like to use this additional space just type y and then press enter and then wait a minute or two takes a few seconds and it will install emacs now to open emacs you simply type emacs right and then it's going to open up something that looks like this now that's literally all i'm going to show you for eback so well i'll show you how to close it as well there's a ton of other commands for emacs again these editors are really just up to your preference you can use whatever you want and there's a few other ones as well i'm just showing kind of the more popular ones but to exit emacs you use control and then z and that will close emacs so there is a lot more to all of these editors the idea behind this video is to give you an introduction allow you to open the editor and close the edit editor which believe it or not is one of the most commonly searched or asked questions how do i get out of him or how do i get out of nano or how do i close emacs in anyways i hope that this video gave you a decent introduction and now you feel at least comfortable enough getting in these editors and doing some really basic things so if you enjoyed the video make sure to leave a like subscribe to the channel and i will see you in another one you

Original Description

In this Linux for programmers tutorial, we're going to be discussing some common Linux text editors, and how to use them. The two text editors that come by default with your Linux distribution are Vim and Nano, which we'll be going over at length. At the end of the video, I'll very quickly show you the Emacs text editor in case you care to use it. 💰 Get a FREE $100 Credit on Linode: https://promo.linode.com/twt/ 📚 Get early access to later videos in the series: https://event.on24.com/wcc/r/2952121/381131E9ADEA3203AEC3413E5A212643/1958924?partnerref=partneryoutube 💻 AlgoExpert is the coding interview prep platform that I used to ace my Microsoft and Shopify interviews. Check it out and get a discount on the platform using the code "techwithtim" https://algoexpert.io/techwithtim ⭐️ Timestamps ⭐️ 00:00 | Intro 01:36 | Nano 06:39 | Vim/Vi 12:35 | Sudo Explanation 13:19 | Emacs 14:33 | Outro 📒 Playlist: https://www.youtube.com/watch?v=ebHX9c75H8I&list=PLzMcBGfZo4-nUIIMsz040W_X-03QH5c5h ◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️ 💰 Courses & Merch 💰 💻 The Fundamentals of Programming w/ Python: https://tech-with-tim.teachable.com/p/the-fundamentals-of-programming-with-python 👕 Merchandise: https://teespring.com/stores/tech-with-tim-merch-shop 🔗 Social Medias 🔗 📸 Instagram: https://www.instagram.com/tech_with_tim 📱 Twitter: https://twitter.com/TechWithTimm ⭐ Discord: https://discord.gg/twt 📝 LinkedIn: https://www.linkedin.com/in/tim-ruscica-82631b179/ 🌎 Website: https://techwithtim.net 📂 GitHub: https://github.com/techwithtim 🔊 Podcast: https://anchor.fm/tech-with-tim 🎬 My YouTube Gear 🎬 🎥 Main Camera (EOS Canon 90D): https://amzn.to/3cY23y9 🎥 Secondary Camera (Panasonic Lumix G7): https://amzn.to/3fl2iEV 📹 Main Lens (EFS 24mm f/2.8): https://amzn.to/2Yuol5r 🕹 Tripod: https://amzn.to/3hpSprv 🎤 Main Microphone (Rode NT1): https://amzn.to/2HrZxXc 🎤 Secondary Microphone (Synco Wireless Lapel System): https://amzn.to/3e07Swl 🎤 Third Micropho
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Tech With Tim · Tech With Tim · 0 of 60

← Previous Next →
1 A* Path Finding Algorithm(Visualization)
A* Path Finding Algorithm(Visualization)
Tech With Tim
2 Python Programming Tutorial #1 - Variables and Data Types
Python Programming Tutorial #1 - Variables and Data Types
Tech With Tim
3 Python Programming Tutorial #2 - Basic Operators and Input
Python Programming Tutorial #2 - Basic Operators and Input
Tech With Tim
4 Python Programming Tutorial #3 - Conditions
Python Programming Tutorial #3 - Conditions
Tech With Tim
5 Python Programming Tutorial #4 - IF/ELIF/ELSE
Python Programming Tutorial #4 - IF/ELIF/ELSE
Tech With Tim
6 Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Tech With Tim
7 Python Programming Tutorial #6 - For Loops
Python Programming Tutorial #6 - For Loops
Tech With Tim
8 Python Programming Tutorial #7 - While Loops
Python Programming Tutorial #7 - While Loops
Tech With Tim
9 Python Programming Tutorial #8 - Lists and Tuples
Python Programming Tutorial #8 - Lists and Tuples
Tech With Tim
10 Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Tech With Tim
11 Python Programming Tutorial #10 - String Methods
Python Programming Tutorial #10 - String Methods
Tech With Tim
12 How to Overclock a NVIDIA GPU
How to Overclock a NVIDIA GPU
Tech With Tim
13 Python Programming Tutorial #11 - Slice Operator
Python Programming Tutorial #11 - Slice Operator
Tech With Tim
14 Python Programming Tutorial #12 - Functions
Python Programming Tutorial #12 - Functions
Tech With Tim
15 Python Programming Tutorial #13 - How to Read a Text File
Python Programming Tutorial #13 - How to Read a Text File
Tech With Tim
16 Python Programming Tutorial #14 - Writing to a Text File
Python Programming Tutorial #14 - Writing to a Text File
Tech With Tim
17 Python Programming Tutorial #15 - Using .count() and .find()
Python Programming Tutorial #15 - Using .count() and .find()
Tech With Tim
18 Python Programming Tutorial #16 - Introduction to Modular Programming
Python Programming Tutorial #16 - Introduction to Modular Programming
Tech With Tim
19 Python Programming Tutorial #17 - Optional Parameters
Python Programming Tutorial #17 - Optional Parameters
Tech With Tim
20 Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Tech With Tim
21 Python Programming Tutorial #19 - Global vs Local Variables
Python Programming Tutorial #19 - Global vs Local Variables
Tech With Tim
22 Python Programming Tutorial #20 - Classes and Objects
Python Programming Tutorial #20 - Classes and Objects
Tech With Tim
23 Cool VBS Script to Prank Your Friends!
Cool VBS Script to Prank Your Friends!
Tech With Tim
24 How to Overclock an AMD GPU
How to Overclock an AMD GPU
Tech With Tim
25 Best GPU'S For Mining Ethereum (2018)
Best GPU'S For Mining Ethereum (2018)
Tech With Tim
26 Recursion and Memoization Tutorial Python
Recursion and Memoization Tutorial Python
Tech With Tim
27 Ethereum Mining Rig - Hardware Guide
Ethereum Mining Rig - Hardware Guide
Tech With Tim
28 Pygame Tutorial #1 - Basic Movement and Key Presses
Pygame Tutorial #1 - Basic Movement and Key Presses
Tech With Tim
29 How to Install Pygame (Windows 8/10)
How to Install Pygame (Windows 8/10)
Tech With Tim
30 How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
Tech With Tim
31 How to Mine Ethereum 2018 - WORKING (Super-Easy)
How to Mine Ethereum 2018 - WORKING (Super-Easy)
Tech With Tim
32 Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Tech With Tim
33 Pygame Tutorial #2 - Jumping and Boundaries
Pygame Tutorial #2 - Jumping and Boundaries
Tech With Tim
34 Pygame Tutorial #3 - Character Animation & Sprites
Pygame Tutorial #3 - Character Animation & Sprites
Tech With Tim
35 Pygame Tutorial #4 - Optimization & OOP
Pygame Tutorial #4 - Optimization & OOP
Tech With Tim
36 OBS Studio Tutorial - Best OBS Settings
OBS Studio Tutorial - Best OBS Settings
Tech With Tim
37 Linear Search Algorithm - Python Example and Code
Linear Search Algorithm - Python Example and Code
Tech With Tim
38 Make Any Mic Sound AMAZING! (WITH OBS)
Make Any Mic Sound AMAZING! (WITH OBS)
Tech With Tim
39 Binary Search Algorithm - Python Example & Code
Binary Search Algorithm - Python Example & Code
Tech With Tim
40 Pygame Tutorial #5 - Projectiles
Pygame Tutorial #5 - Projectiles
Tech With Tim
41 Pygame Game - Mini Golf
Pygame Game - Mini Golf
Tech With Tim
42 Pygame Tutorial - Projectile Motion (Part 1)
Pygame Tutorial - Projectile Motion (Part 1)
Tech With Tim
43 Pygame Tutorial - Projectile Motion (Part 2)
Pygame Tutorial - Projectile Motion (Part 2)
Tech With Tim
44 Pygame Tutorial #6 - Enemies
Pygame Tutorial #6 - Enemies
Tech With Tim
45 Pygame Tutorial #7 - Collision and Hit Boxes
Pygame Tutorial #7 - Collision and Hit Boxes
Tech With Tim
46 Pygame Tutorial #8 - Scoring and Health Bars
Pygame Tutorial #8 - Scoring and Health Bars
Tech With Tim
47 Cloud Mining vs. Hardware Mining - 2018
Cloud Mining vs. Hardware Mining - 2018
Tech With Tim
48 How to Install Pygame on Mac OSX (Fast-Simple)
How to Install Pygame on Mac OSX (Fast-Simple)
Tech With Tim
49 Pygame Tutorial #9 - Sound Effects, Music & More Collision
Pygame Tutorial #9 - Sound Effects, Music & More Collision
Tech With Tim
50 Pygame Tutorial #10 - Finishing Touches & Next Steps
Pygame Tutorial #10 - Finishing Touches & Next Steps
Tech With Tim
51 How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
Tech With Tim
52 How to Create a Button in Pygame [CODE IN DESCRIPTION]
How to Create a Button in Pygame [CODE IN DESCRIPTION]
Tech With Tim
53 Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Tech With Tim
54 Pygame Side-Scroller Tutorial #2 - Random Object Generation
Pygame Side-Scroller Tutorial #2 - Random Object Generation
Tech With Tim
55 Pygame Side-Scroller Tutorial #3 - Collision
Pygame Side-Scroller Tutorial #3 - Collision
Tech With Tim
56 Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Tech With Tim
57 How to Create A Message Box in Python - Tkinter
How to Create A Message Box in Python - Tkinter
Tech With Tim
58 Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Tech With Tim
59 How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
Tech With Tim
60 Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Tech With Tim

This video teaches the basics of Linux text editors, including Nano, Vim, and Emacs, and demonstrates how to use them for editing and managing files in a Linux environment. Viewers will learn how to navigate and use the features of each editor, as well as how to install and access them. The video is geared towards beginners who want to learn the fundamentals of Linux and text editing.

Key Takeaways
  1. Type nano to access the editor
  2. Type nano followed by the file name to create or edit a file
  3. Use control S to save the current file
  4. Use control O to save as a different file name
  5. Use control C to cancel
  6. Mark a position in nano using control + 6 or control + hat
  7. Select text in nano using cursor
  8. Copy text in nano using alt + 6 or alt + hat
  9. Paste text in nano using control + u
  10. Cut text in nano using control + k
💡 The video highlights the importance of understanding the basics of Linux text editors, including Nano, Vim, and Emacs, in order to effectively manage and edit files in a Linux environment.

Related Reads

Chapters (6)

| Intro
1:36 | Nano
6:39 | Vim/Vi
12:35 | Sudo Explanation
13:19 | Emacs
14:33 | Outro
Up next
Google Just Dropped A FREE Marketing Agent And It's INSANE (Pomelli)
Income stream surfers
Watch →