<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Stephan Bakkelund Valois</title>
    <description>The latest articles on DEV Community by Stephan Bakkelund Valois (@devalo).</description>
    <link>https://dev.to/devalo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F374670%2F83441d45-c8da-434a-80df-5bf38c2a8a2d.jpeg</url>
      <title>DEV Community: Stephan Bakkelund Valois</title>
      <link>https://dev.to/devalo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devalo"/>
    <language>en</language>
    <item>
      <title>How Algorithms and Big O Notation Works. In An Understandable Manner.</title>
      <dc:creator>Stephan Bakkelund Valois</dc:creator>
      <pubDate>Tue, 21 Jul 2020 11:35:20 +0000</pubDate>
      <link>https://dev.to/devalo/how-algorithms-and-big-o-notation-works-in-an-understandable-way-55a</link>
      <guid>https://dev.to/devalo/how-algorithms-and-big-o-notation-works-in-an-understandable-way-55a</guid>
      <description>&lt;p&gt;Such scary words. It oozes math all over them…&lt;br&gt;
This is probably what you’re thinking if you’re new to computer science and programming. But really, they aren’t that hard to grasp, once you understand the basics of them.&lt;/p&gt;

&lt;p&gt;the Big-O is a way of figuring out how efficient an algorithm is. When you’re working on a big project with a huge database, making your code run as efficient as possible can save huge costs in the long run. You may ask — What is an algorithm?&lt;/p&gt;
&lt;h2&gt;
  
  
  Algorithms
&lt;/h2&gt;

&lt;p&gt;You can think of an algorithm as a recipe. A set of instructions on how to complete a task. Imagine getting a glass of milk. The algorithm for doing such a task might look something like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Open cupboard&lt;/li&gt;
&lt;li&gt; Get a glass from the cupboard&lt;/li&gt;
&lt;li&gt; Close cupboard&lt;/li&gt;
&lt;li&gt; Open fridge&lt;/li&gt;
&lt;li&gt; Take the milk carton out of the fridge&lt;/li&gt;
&lt;li&gt; Open milk carton&lt;/li&gt;
&lt;li&gt; Pour milk into the glass&lt;/li&gt;
&lt;li&gt; Close milk carton&lt;/li&gt;
&lt;li&gt; Put milk carton back into the fridge&lt;/li&gt;
&lt;li&gt;Close fridge&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is an algorithm. It explains every step of getting a glass of milk, assuming there are glasses in the cupboard, and milk in the fridge.&lt;/p&gt;

&lt;p&gt;You might have heard about different search algorithms and such. They are also just instructions on how to search for something, within some data.&lt;/p&gt;

&lt;p&gt;A very popular search algorithm is the binary search. It sounds very computery, but it’s actually an algorithm you’ve used many times throughout your life. The binary search basically splits the data in half, checks which side of the split the data you’re searching for is, and repeating the cycle until you found what you’re looking for.&lt;/p&gt;

&lt;p&gt;Imagine you’re looking for Todd Jefferson’s phone number in the phone book. The phone book is going to be in alphabetical order, ordered by the last name. You wouldn’t look for Jefferson at page 1, where the last names begin with an A. You could turn to the next page, and repeat until you got to J. But you probably wouldn’t. Because it’s very ineffective, and this is something you just know unconsciously.&lt;/p&gt;

&lt;p&gt;What you probably would be doing, is to go to somewhere in the middle. Maybe you end up at a page which shows last names beginning with M. Since you know J is before M, anything after M is useless information in this context. Now, you might try to split the phone book again. Maybe you’ll end up at F. And again, everything before F is useless information, since J is after F. We’ll loosely repeat this process until we find Tod Jeffersons phone number.&lt;/p&gt;

&lt;p&gt;I say loosely, because your subconsciousness is incredible efficient in solving these types of math problems, and you might find it more efficient to turn the page to Tods phone number, if you know that would be more efficient than splitting the data again.&lt;/p&gt;

&lt;p&gt;A computer doesn’t have subconsciousness. Nor does it have conscious. The computer is a loyal servant. It does exactly what you tell it to. No more, no less.&lt;/p&gt;

&lt;p&gt;There are many pre-made algorithms, created by very smart people. These include ways of sorting data, moving data, manipulating strings and more. Very high-level languages (Python, Ruby, JavaScript etc) often come with predefined functions, or “wrappers” of these efficient algorithms, so that you don’t have to write them yourself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example in Python&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list_of_numbers = [2, 1, 3, 5, 4]
list_of_numbers.sort()
print(list_of_numbers)

output: [1, 2, 3, 4, 5]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The sort function in python is actually a sorting algorithm called Timsort which you can read more about here: &lt;a href="https://en.wikipedia.org/wiki/Timsort"&gt;https://en.wikipedia.org/wiki/Timsort&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The point in this example is to show you that this simple, short little function you append to your data, is actually an advanced sorting algorithm behind the scenes. Python takes all the hard stuff and puts it in a built in function for you to use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example in JavaScript&lt;/strong&gt;&lt;br&gt;
JavaScript comes with a prebuilt sorting function, which you append to a set of data. Consider this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let listOfNumbers = [2, 1, 3, 5, 4];
listOfNumbers.sort();
console.log(listOfNumbers);

output: [1, 2, 3, 4, 5]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;JavaScript has the same built in sorting function as Python has. Which algorithm does JavaScript use? It actually depends on where you run your JavaScript code. Each browser is free to implement their own sorting algorithm. For instance, Google’s V8 JavaScript engine (Chrome, Node.js etc) also uses Timsort, while Mozilla Firefox uses merge sort.&lt;/p&gt;

&lt;p&gt;In a lower level programming language like C, you wouldn’t have any of these high level functions. Everything has to be coded manually. If you want to sort data in C, you need to figure out how you want to sort the data. In other words — which algorithm you’d use to sort the data, and implement it programmatically.&lt;br&gt;
To recap algorithms, it’s not a scary word. It’s just a recipe — a set of instructions on how to do a task. We are using algorithms consciously and subconsciously many times every day.&lt;/p&gt;
&lt;h2&gt;
  
  
  Big O Notation
&lt;/h2&gt;

&lt;p&gt;The reason I included some info about algorithms, is because the Big O and algorithms go hand in hand. As noted earlier, Big O Notation is all about the efficiency of the algorithm.&lt;/p&gt;

&lt;p&gt;You can put it this way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How long does it take the computer to do a certain task&lt;/li&gt;
&lt;li&gt;How much memory will the computer use while doing a certain task&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Big O always describes the worst case scenario of the efficiency of an algorithm. Let’s have a look at some common orders of growth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;O(1)&lt;/strong&gt;&lt;br&gt;
O(1) means constant. We use the number 1, to signalize a constant value. The number 1 will never change. 1 will always be 1.&lt;br&gt;
It will always take the same amount of time to execute an O(1) operation.&lt;/p&gt;

&lt;p&gt;Example, O(1):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myArray = [1, 2, 3]
myArray[1]

output: 2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In this example, we’re getting the value of the array at index 1. Since computers know the index of the arrays, searching up an index would be constant. It doesn’t matter how big the array is. It will take the same amount of time to look up an index whether the array consists of 3 elements, or 5000 elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;O(n)&lt;/strong&gt;&lt;br&gt;
O(n) means linear time. You can think of the n as number of data. The time it takes to execute a O(n) operation depends on how much data we have. Let’s look at another example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# PYTHON 
my_list = [1, 2, 3, 4, 5]
for number in my_list:
  print(number)

# JS 
const myArray = [1, 2, 3, 4, 5];
for(let i = 0; i &amp;lt; myArray.length; i++) {
  console.log(myArray[i]);
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Both these snippets of code will produce the same outcome. It will spit out the content of the array. When we iterate over data like this. the size of the data will determine how long it will take to iterate over it.&lt;/p&gt;

&lt;p&gt;An operation we do a lot of times, is to search through data. Let’s look at an example where we do a linear search through an array. How would this algorithm look like?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Loop over the array&lt;/li&gt;
&lt;li&gt;Check value&lt;/li&gt;
&lt;li&gt;Is the value the value I’m looking for?&lt;/li&gt;
&lt;li&gt;If it is — perfect, we found our number. Exit program.&lt;/li&gt;
&lt;li&gt;If not — go to next value and repeat stage 2.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# PYTHON
arr = [1, 2, 3, 4]
def search(arr, number):
  for i in range(len(arr)):
    if arr[i] == number:
      return print("Number is in array")
  return print("Number is not in array")
search(arr, 4)

output: Number is in array

# JS
const arr = [1, 2, 3, 4, 5];
const search = (arr, item) =&amp;gt; {
  for(let i = 0; i &amp;lt; arr.length; i++) {
    if (arr[i] === item){
      return "Number is in array";
    }
  }
  return "Number is not in array";
}
search(arr, 6)

output: Number is not in array
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the best case, this algorithm is O(1). if the value we’re looking for is the first value in the array. But it might not be. And the array could be huge, with hundreds of values. In the worst case scenario, we would have to iterate through the whole array to find the value we’re looking for. This makes it O(n).&lt;/p&gt;

&lt;p&gt;If you run two loops right after each other in the same scope, we’ll get a complexity O(2n), because we get n two times. In Big O Notation, we remove the constant. Which means, O(2n), O(3n) and on is still written as O(n)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;O(n²)&lt;/strong&gt;&lt;br&gt;
What is this scary looking thing? It sure starting to look mathy now! That’s what I thought when I first saw this.&lt;/p&gt;

&lt;p&gt;This complexity is close to O(n), but it’s a pretty bad operation. Which means, the computer will need to do a lot of calculations in an operation with big O of O(n²). Is this always bad? Should you never use algorithms with this order of growth? The short answer is — yes, you should not. You should figure out a different way of solving whatever you’re working on. The long answer is — it depends. There are times where these algorithms are the only ones that will work. And that’s ok. Just be aware of it, and try to come up with better ways of solving things.&lt;/p&gt;

&lt;p&gt;Let’s look at an example, and figure out why O(n²) is so slow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# PYTHON 
num_list = [1, 2, 3]
letter_list = ['a', 'b', 'c']

for number in num_list:
    print(number)
    for letter in letter_list:
        print(letter)

output: 1, a, b, c, 2, a, b, c, 3, a, b, c

# JS 
const numArr = [1, 2, 3];
const letterArr = ['a', 'b', 'c'];
for(let i = 0; i &amp;lt; numArr.length; i++){
  console.log(numArr[i]);
  for (let j = 0; j &amp;lt; letterArr.length; j++){
    console.log(letterArr[j]);
  };
};

output: 1, a, b, c, 2, a, b, c, 3, a, b, c
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here is a program that consists of two nested loops. At the outer loop first iteration, the whole inner loop runs. Looking at the example above, when the outer loop goes to 1, the inner loop has to do a complete iteration before the outer loop moves over to 2. This operation runs in quadratic time. If the array has 10 items, we have to print 100 times. If it has 1000 items, we have to print 1000000 times.&lt;/p&gt;

&lt;p&gt;O(n²) might work for smaller programs and operations, but you can see how inefficient it would be when working on huge datasets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;O(log n)&lt;/strong&gt;&lt;br&gt;
This is probably the scariest of all the complexities. The O(log n) follows the logarithmic scale. It will perform better the more data it runs. On large datasets, this is the second best complexity, only beaten by O(1).&lt;/p&gt;

&lt;p&gt;For example, when we perform a binary search, we will divide the data in two, and only work with the part where the data we search for probably is. We will continue to do this until we find, or don’t find our value&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--24bNeHxB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rnmeoapno6cfwrjbtzlv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--24bNeHxB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rnmeoapno6cfwrjbtzlv.png" alt="Big O complexities"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s take a look at this chart. All the graphs should start to make sense, and they clearly visualize how efficient the different time complexities are. We are lucky to have such higher languages, that hides all this complicated stuff from us so that we can concentrate on building cool apps. However it’s still important to understand how it works under the hood.&lt;/p&gt;

&lt;p&gt;Until next time&lt;br&gt;
Stephan Bakkelund Valois&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>bigonotation</category>
      <category>programming</category>
      <category>efficiency</category>
    </item>
    <item>
      <title>Beginning Vim (and using Vim in other text editors)</title>
      <dc:creator>Stephan Bakkelund Valois</dc:creator>
      <pubDate>Sat, 04 Jul 2020 09:32:33 +0000</pubDate>
      <link>https://dev.to/devalo/beginning-vim-and-using-vim-in-other-text-editors-36cm</link>
      <guid>https://dev.to/devalo/beginning-vim-and-using-vim-in-other-text-editors-36cm</guid>
      <description>&lt;p&gt;Today, I want to write a bit about Vim, using Vim keybindings. and why you should use switch to Vim keybindings if you’re not already using them.&lt;/p&gt;

&lt;p&gt;Me, as well as many others started hearing about this arcane text editor when we first started learning programming. What is it with this 30 years old editor, that makes it so intriguing?&lt;/p&gt;

&lt;p&gt;First of all, about all Linux servers have Vim installed. This means if you were to SSH into a server, you would probably use Vim to open and edit files containing text, be it regular text files, source code, or what have you.&lt;/p&gt;

&lt;p&gt;A lot of people like the Vim editor because it’s very hackable. You can build a customized fully-fledged IDE just by installing a few Vim-addons.&lt;/p&gt;

&lt;p&gt;Now, I don’t use Vim as my main text editor anymore. Like so many others, I made a switch to Visual Studio Code. And I can tell you, &lt;em&gt;I would’ve never made the switch if it wasn’t for Vim keybindings.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That’s one of the dangers by learning Vim keybindings. They’re just so good, you never want to go back to the wrong way of editing text.&lt;/p&gt;

&lt;p&gt;Now, you’ve probably heard that Vim is incredible hard. That’s a lie. You can do some pretty amazing, very advanced editing in Vim. This isn’t something you usually need to use all the time. The regular coding, day to day work doesn’t require incredible advanced Vim-skills. It will just be a bit different than what you’re used to.&lt;/p&gt;

&lt;p&gt;If you are running Linux or Mac OS, you can fire up Vim by typing Vim in the terminal. If you’re on Windows, I recommend you install gVim from &lt;a href="http://www.vim.org"&gt;www.vim.org&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  TABLE OF CONTENTS
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Vim modes&lt;/li&gt;
&lt;li&gt;Vim: Create new file, write , save, and close&lt;/li&gt;
&lt;li&gt;Moving around in Vim&lt;/li&gt;
&lt;li&gt;Let’s edit something&lt;/li&gt;
&lt;li&gt;Visual Mode&lt;/li&gt;
&lt;li&gt;Vim MISC&lt;/li&gt;
&lt;li&gt;Vim in other text editors?&lt;/li&gt;
&lt;li&gt;Closing thoughts&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Vim Modes &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;Doing a quick google search shows us what we need to go over first. There are plenty of memes about quitting a Vim session out there. If you’re unfamiliar about how Vim works, it’s understandable. If you are familiar with it, you wouldn’t want it any other way. (Looking at you, Google Docs!)&lt;/p&gt;

&lt;p&gt;Let’s try opening Vim. Open up a terminal window, and enter vim&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~ % vim
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--msicVYbb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/x54s8ye95mfmxftr4jrv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--msicVYbb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/x54s8ye95mfmxftr4jrv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The famous Vim start-page.&lt;/p&gt;

&lt;p&gt;One of the main reasons people are actually googling how to exit Vim, is because they’re not familiar to Vim’s modular approach.&lt;br&gt;
When you first start up Vim, you are in &lt;em&gt;Normal Mode&lt;/em&gt;. Vim has multiple different modes, where the most important ones are &lt;em&gt;Normal Mode, Insert Mode and Visual Mode&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Normal Mode overview&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Normal Mode&lt;/em&gt; is used for navigating through the file and doing edits. If you try to enter text in &lt;em&gt;Normal Mode&lt;/em&gt;, nothing will be printed out.&lt;br&gt;
When programming, most of the time you spend in the text editor is spent editing and looking trough the code, not actually writing code. This is one of the reasons it makes perfect sense to have &lt;em&gt;Normal Mode&lt;/em&gt; as Vim’s default mode.&lt;br&gt;
&lt;strong&gt;You return to &lt;em&gt;Normal Mode&lt;/em&gt; by pressing Esc on your keyboard.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Insert Mode overview&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Insert Mode&lt;/em&gt; is used for inserting text into the document. It will behave as a regular text program. Which means you are also able to use backspace to delete text. If you have to delete more than a couple of characters, you should probably do that in &lt;em&gt;Normal Mode&lt;/em&gt;. We’ll get back to that shortly!&lt;br&gt;
&lt;strong&gt;You enter &lt;em&gt;Insert Mode&lt;/em&gt; by pressing i on your keyboard.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Visual Mode overview&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Visual Mode&lt;/em&gt; is used to highlight text, the same way you would do when you drag your mouse over a piece of text to copy it.&lt;br&gt;
&lt;strong&gt;You enter &lt;em&gt;Visual Mode&lt;/em&gt; by pressing shift+v or v on your keyboard.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h1&gt;
  
  
  Vim: Create new file, write , save, and close &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--d8Vo-6Fr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gw3oa29wh4isxoefnjoi.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d8Vo-6Fr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gw3oa29wh4isxoefnjoi.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s see whats going on here.&lt;br&gt;
From the terminal, I’m first opening Vim. I’m appending a -clean. This is just so that I’m able to show you Vim without any addons. My Vim has quite a few addons, which may take the focus off of the actual editor.&lt;/p&gt;

&lt;p&gt;We can change from &lt;em&gt;Normal Mode&lt;/em&gt; to &lt;em&gt;Insert Mode&lt;/em&gt; by pressing the i key. Once pressed, Vim shows us that we’re currently in &lt;em&gt;Insert Mode&lt;/em&gt; by displaying INSERT in the lower left corner.&lt;/p&gt;

&lt;p&gt;Once we’re in &lt;em&gt;Insert Mode&lt;/em&gt;, we can write text as usual. When we’re done writing text, we exit &lt;em&gt;Insert Mode&lt;/em&gt; by pressing the ESC-key on our keyboard. Vim shows us that we’re currently in Normal Mode, by not displaying anything in the lower left corner.&lt;/p&gt;

&lt;p&gt;Now comes an interesting part. To save the text as a new file, we use the write command. We type :w followed by whatever we want our file to be named. Once saved, we may exit Vim by using the quit command, :q&lt;/p&gt;

&lt;p&gt;Note that if you try to exit Vim without saving your file, you’ll run into an error:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I4IOQhF2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mhdnsr7oicg7xncpcfvl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I4IOQhF2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mhdnsr7oicg7xncpcfvl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you don’t want to save your work, just follow the instructions, and add a ! to override Vim’s safety net. :q!&lt;br&gt;
Note that you can save and exit Vim by concatenating the commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:qw &amp;lt;filename&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;or omit the filename if you’ve edited an already existing file&lt;/p&gt;




&lt;h1&gt;
  
  
  Moving around in Vim &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--42_sAeoi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nw8wujkwytfbbfrrfpqg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--42_sAeoi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nw8wujkwytfbbfrrfpqg.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You might think — What’s so special about this? We’re just using the arrow keys to move around. Well, not quite.&lt;/p&gt;

&lt;p&gt;When using Vim, we should not use the arrow keys. We use the keys h, j, k and l instead.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;h to move left&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;j to move down&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;k to move up&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;l to move right&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, these are some weird keybindings! And I totally agree. This is probably one of the weirdest things about Vim. These keybindings are actually quite common in the terminal world. If you were to use less or more to look inside a file, you could use the same keybindings to scroll through it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oVZ5WsYM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qyj47sgqy3efbjt2vd1j.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oVZ5WsYM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qyj47sgqy3efbjt2vd1j.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we can see a couple of other commands for moving around. Let’s go through them:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e&lt;/strong&gt;&lt;br&gt;
When pressing the e key, we move to the end of the word, or the end of the next word, depending on where the cursor is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b&lt;/strong&gt;&lt;br&gt;
When pressing the b key, we move to the start of the word, or the start of the previous word, depending on where the cursor is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;$&lt;/strong&gt;&lt;br&gt;
A dollar sign will move you all the way to the end of the line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;0&lt;/strong&gt;&lt;br&gt;
A zero will move you back, to the start of the line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Number before a move command&lt;/strong&gt;&lt;br&gt;
If you write a number before the move command, Vim will execute the command the number of times you’ve entered.&lt;br&gt;
If you type 10e, Vim will move 10 words ahead. If you type 3j, Vim will move down 3 lines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;gg&lt;/strong&gt;&lt;br&gt;
This command will move you to the start of the document.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shift+g&lt;/strong&gt;&lt;br&gt;
This command will move you to the last line of the document.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Number + shift+G&lt;/strong&gt;&lt;br&gt;
Do you know which line number you’re moving to? Say you need to do some work at line 56. just type out 56, and press shift+G. Easy!&lt;/p&gt;


&lt;h1&gt;
  
  
  Let’s edit something &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zo8-IgXt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/akhcq4kntxb5wf1vhe92.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zo8-IgXt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/akhcq4kntxb5wf1vhe92.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Editing is done in &lt;em&gt;Normal Mode&lt;/em&gt;. We only enter &lt;em&gt;Insert Mode&lt;/em&gt; to do small bursts of text insertions. There are an incredible amount of different commands for different edits. This topic goes so deep, entire books have been written on this subject. Let’s go through the ones I use the most throughout the day.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;u&lt;/strong&gt;&lt;br&gt;
I wanted to show you this command first. This is equivalent to ctrl+z on Linux and Windows, and cmd+z on mac. Why it’s important is pretty self explanatory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;i&lt;/strong&gt;&lt;br&gt;
To enter &lt;em&gt;Insert Mode&lt;/em&gt;, and start writing, we press i.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ctrl+r&lt;/strong&gt;&lt;br&gt;
Redo. Goes hand in hand with undo, or u.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;daw&lt;/strong&gt;&lt;br&gt;
Stands for ‘delete a word’, and will delete the entire word.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ciw / caw&lt;/strong&gt;&lt;br&gt;
Stands for ‘change word’. the command deletes the word, and put you directly in &lt;em&gt;Insert Mode&lt;/em&gt;. The difference between these commands, is that ciw will leave a space, while caw will will jump to the first character of the next word.&lt;/p&gt;

&lt;p&gt;Try it yourself. Write out two words. Jump back to the first word, and try out both commands. Which one do you like best? If you ask me, ciw is the way to go. It might be one of the most useful commands in Vim.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;cw&lt;/strong&gt;&lt;br&gt;
This command deletes a word from the cursor, which means everything before the cursor will be left alone.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CONSIDER THIS TEXT:
const newNumber;
CURSOR ON N:
const newNumber;
         ^
USE cw:
const new
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As we can see from the example, the text got deleted at the cursor, and Vim put us in &lt;em&gt;Insert Mode&lt;/em&gt;. as you may see, this makes for very quick text edits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;dd&lt;/strong&gt;&lt;br&gt;
This command will delete an entire line of text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d$&lt;/strong&gt;&lt;br&gt;
This command will delete from the cursor, and to the end of the line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d0&lt;/strong&gt;&lt;br&gt;
This command will delete from the cursor, and to the beginning of the line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;x&lt;/strong&gt;&lt;br&gt;
x will delete the character underneath the cursor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;di} di) di] di” di’&lt;/strong&gt;&lt;br&gt;
And so on, and so forth. These commands are very, very useful if you’re editing code. Think of it like this: ‘delete inside bracket’, ‘delete inside quotes’.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CONSIDER THIS MOCK VARIABLE
const variable = {...something, id: newId};
MOVE CURSOR SOMEWHERE INSIDE THE BRACKETS 
const variable = {...something, id: newIid};
                    ^
TYPE ci} 
const variable = {};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The example above works with all types of brackets, single and double quotes. It is an amazing way to delete inside, and makes for very efficient text editing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RPn2hXmQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tcfncp2bxucoknshf1zd.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RPn2hXmQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tcfncp2bxucoknshf1zd.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;yy&lt;/strong&gt;&lt;br&gt;
y stands for yank. This command will duplicate a whole line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;p&lt;/strong&gt;&lt;br&gt;
paste (put). If you use it after yy, you paste the line you just duplicated. This command also works with deletion of words. So if you need to delete a word and paste it in another place, you delete it, move the cursor to where you want to paste it in, and press p.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;yw / yiw&lt;/strong&gt;&lt;br&gt;
Works the same as deleting words, except these commands will copy them. You may use p to paste them again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;o&lt;/strong&gt;&lt;br&gt;
o will enter &lt;em&gt;Insert Mode&lt;/em&gt; on a new line, underneath the cursor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;O&lt;/strong&gt;&lt;br&gt;
O will enter &lt;em&gt;Insert Mode&lt;/em&gt; on a new line, above the cursor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;r&lt;/strong&gt;&lt;br&gt;
replaces the character underneath the cursor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;br&gt;
This command will repeat the last change you’ve made.&lt;br&gt;
Remember, you can always add numbers to a command, to make Vim repeat it.&lt;/p&gt;




&lt;h1&gt;
  
  
  Visual Mode &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n5VXuwsE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b1ptb0pw8vtw67qwbgl6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n5VXuwsE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b1ptb0pw8vtw67qwbgl6.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Visual Mode&lt;/em&gt; will let you highlight text, the same way you often do with your mouse. What’s nice about Visual Mode, is that it can very easily copy or delete big sections of text.&lt;br&gt;
As far as I’m concerned, there are two main ways of entering &lt;em&gt;Visual Mode&lt;/em&gt;, and they work a bit different:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;v&lt;/strong&gt;&lt;br&gt;
v will enter &lt;em&gt;Visual Mode&lt;/em&gt; from where the cursor is, and let you highlight text relative to the cursors position when you entered &lt;em&gt;Visual Mode&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--REz6nRY5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6r4xs91m67emzp4qfx6k.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--REz6nRY5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6r4xs91m67emzp4qfx6k.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that it says ‘Visual’ instead of ‘Insert’, while in &lt;em&gt;Visual Mode&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shift + v&lt;/strong&gt;&lt;br&gt;
This will highlight line by line. This is a command I’m using all the time.&lt;br&gt;
It makes it very easy to select chunks of text.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_JWEBEvp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dttq5q00fdgt2lnxpn7z.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_JWEBEvp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dttq5q00fdgt2lnxpn7z.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  Vim MISC &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;We are getting near the end of this little Vim keybinding tutorial. There are a couple of other commands that I use frequently, that doesn’t belong in any of the sections above.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Search for text&lt;/strong&gt;&lt;br&gt;
In &lt;em&gt;Normal Mode&lt;/em&gt;, there is a search function pretty similar to the one you you’re used to from web browsers, and such. By using a slash followed by the word you’re looking for, you’re able to search through the entire document, jumping from a matched word, to the next matched word.&lt;br&gt;
&lt;em&gt;/word-to-find&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ebtBnBQo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9ojsxdwmfn5xg05oe4vv.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ebtBnBQo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9ojsxdwmfn5xg05oe4vv.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Replace all characters&lt;/strong&gt;&lt;br&gt;
Say you did a mistake. You’ve created a bad variable name, and you need to change it. However, you’ve used the variable name in 10 different places. It could potentially take some time to replace them all. Or, maybe there was an easy way to do this? Well, this is Vim. Of course there is an easy, yet arcane way to do it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2JM1uhvj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cfzqi0n7sa0c0310gcl2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2JM1uhvj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cfzqi0n7sa0c0310gcl2.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;:s stands for substitute.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;:s/old-word/new-word&lt;/strong&gt;&lt;br&gt;
This command will replace the old word, with the new word, on the line which the cursor is currently on.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;:%s/old-word/new-word/g&lt;/strong&gt;&lt;br&gt;
Note the percent character. This command will replace every old word with the new word, throughout the entire document.&lt;/p&gt;




&lt;h1&gt;
  
  
  Vim in other text editors? &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;As I wrote a bit earlier in this post, I don’t use Vim text editor at the moment. I use Visual Studio Code. Before that, I used Atom. I’m lazy, and it’s a lot easier to use one of these big, new shiny toys than building and customizing my own. I can guarantee that if it wasn’t for Vim bindings, I wouldn’t have touched any of the new text editors. You see, after using Vim and Vim keybindings for a while, you will get so used to them, to a point where it’s nearly impossible not to use them.&lt;/p&gt;

&lt;p&gt;You don’t need to set up Vim, if you don’t want to. Just enable Vim Mode in the text editor you’re currently using. All the commands I’ve showed you so far, works in all of them.&lt;/p&gt;




&lt;h1&gt;
  
  
  Closing thoughts &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;If you’ve read all the way to here, I’m pretty sure you will give these amazing keybindings a try. Or even have a shot at the real thing. There are so many plugins for Vim, you wouldn’t believe it. The text editor itself is also actively maintained. Not bad for a 30 years old piece of software!&lt;/p&gt;

&lt;p&gt;If you’re touch typing (as you should!), you’ll notice that many of the commands are laid out very conveniently. This means you don't have to move your hands that much while editing text. You don’t need to use your mouse either. You can keep your fingers at the correct position. This can shave off some time you would have spent on moving your arm to your mouse, and moving your hand over to the arrow keys.&lt;/p&gt;

&lt;p&gt;If you are serious about learning Vim, but find the standard commands hard to remember, why not learn it by playing a game? There is a game called Vim adventures, where.. Well, I won’t spoil anything. It’s pretty amazing. It does cost money for a premium version, but you can pick up quite a bit if you only want to do the free one. Check out &lt;a href="https://vim-adventures.com/"&gt;https://vim-adventures.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are an incredible amount of commands, and ways of combining commands. A lot more than what I’ve written about. Entire books have been written on the subject. This blog post barely scratches the surface of what’s possible with Vim commands. But to be honest, these are the commands I use the most, and I like to think about my self as a fairly efficient Vim user. If I need to create a special macro for some weird and clunky editing task, I can always google it.&lt;/p&gt;

&lt;p&gt;I hope this have been informative and that you find it helpful&lt;br&gt;
Until next time&lt;/p&gt;

&lt;p&gt;Stephan Bakkelund Valois&lt;/p&gt;

</description>
      <category>vim</category>
      <category>editor</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>Beginning Linux and Mac terminal</title>
      <dc:creator>Stephan Bakkelund Valois</dc:creator>
      <pubDate>Mon, 22 Jun 2020 12:14:05 +0000</pubDate>
      <link>https://dev.to/devalo/beginning-linux-and-mac-terminal-4j4c</link>
      <guid>https://dev.to/devalo/beginning-linux-and-mac-terminal-4j4c</guid>
      <description>&lt;p&gt;For the complete beginner, and for those who just need a quick refresh. If you use Linux as your primary OS, this blog post is probably not for you.&lt;/p&gt;

&lt;p&gt;If you’re thinking about doing any sorts of computer programming, development, or working with servers, you probably should get used to working with in a terminal window. Even if you’re just tired of Windows, switching to Linux could be very good for you.&lt;/p&gt;

&lt;p&gt;Now, if you want to work with Microsoft products, that might be a different story. I’m not too familiar with the .NET platform, so this post won’t touch on any of that.&lt;/p&gt;

&lt;p&gt;There are an incredible amount of software out there, created to help programmers build cool stuff. Most of them are Command Line Applications. You do have some programs that comes with a GUI, but most of them started out, or also have a Command Line version of the application.&lt;/p&gt;

&lt;p&gt;Most of the things you do in a GUI environment, you can do in a terminal. Be it working with files, downloading from the internet, writing, and so forth. This blog post focuses on the basic terminal commands. It won’t make you an expert, but it will allow you to navigate, and work in the terminal with confidence.&lt;/p&gt;

&lt;p&gt;PS: If you don’t have access to a linux terminal, you can find many online terminals to play around with for free. For example &lt;a href="https://cocalc.com/doc/terminal.html"&gt;https://cocalc.com/doc/terminal.html&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;ls&lt;/h2&gt;

&lt;p&gt;Short for list, this command lists all files and folders in a directory.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~ $ ls&lt;br&gt;
file.py ingredients.txt secret_folder&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;As we can see, our current directory consists of 3 items — 2 files and a super secret folder. we can have a peak into the folder from our current directory. Since the secret_folder is inside our current directory, we can use the ls command, followed by the folder name&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~ $ ls secret_folder/&lt;br&gt;
nintendo_cheat_codes.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Cool. the secret_folder contains a file. Now, how can we navigate into the folder?&lt;/p&gt;

&lt;h2&gt;cd&lt;/h2&gt;

&lt;p&gt;This command is short for change directory. At a basic level, you can use it the same way as ls. You enter cd, followed by the directory you want to navigate to&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~ $ cd secret_folder/&lt;br&gt;
~/secret_folder $ ls&lt;br&gt;
nintendo_cheat_codes.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So we cd into the secret_folder directory, and run the command ls to list the files inside of the directory. What if we want to go back to the previous directory?&lt;/p&gt;

&lt;h2&gt;‘..’ and ‘.’&lt;/h2&gt;

&lt;p&gt;Dots? Well, yeah. Those dots have a special meaning in a terminal window. one dot means this current directory, while two dots means the parent directory, or the directory your current directory sits in. The two dots will help us navigating to the previous directory&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/secret_folder $ cd ..&lt;br&gt;
~/ $ ls&lt;br&gt;
file.py ingredients.txt secret_folder&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So now we know how to change directories, and how to list the files and folders inside of them. If you ask me, running these commands are a lot less work than physically moving your hand over to your computer mouse and clicking stuff!&lt;/p&gt;

&lt;h2&gt;pwd&lt;/h2&gt;

&lt;p&gt;So, how can we keep track on where we are, relative to the root? The pwd command is short for Print Working Directory and will show you exactly where you are.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~ $ pwd&lt;br&gt;
/home/myuser&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;mkdir&lt;/h2&gt;

&lt;p&gt;How can we create new folders? We can use the mkdir command, which stands for Make Directory. We type in the command, followed by the name of our new directory&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/ $ mkdir not_so_secret_folder&lt;br&gt;
~/ $ ls&lt;br&gt;
file.py ingredients.txt not_so_secret_folder secret_folder&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;As we can see by listing the items in our current directory, our newly added directory got created.&lt;/p&gt;

&lt;h2&gt;touch&lt;/h2&gt;

&lt;p&gt;This command is probably the easiest way to create any file you want. You type in the command, followed by the filename WITH the file extension.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/ $ touch new_file.txt&lt;br&gt;
~/ $ ls&lt;br&gt;
new_file.txt&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;rm&lt;/h2&gt;

&lt;p&gt;If you want to remove files or folders, there are a couple of commands you can use. The easiest one is probably the command rm, which stands for Remove.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/ $ ls&lt;br&gt;
new_file.txt&lt;br&gt;
~/ $ rm new_file.txt &lt;br&gt;
~/ $ ls&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So if we list our files, we can see the file we just created with touch. By using rm, followed by the filename, we’ll delete the file. What about folders?&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/ $ mkdir to_be_deleted&lt;br&gt;
~/ $ ls&lt;br&gt;
to_be_deleted&lt;br&gt;
~/ $ rm to_be_deleted/&lt;br&gt;
rm: cannot remove ‘to_be_deleted/’: Is a directory&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We get an error. In linux, we are not able to delete directories! Well, that’s a lie. We just need to use a flag! What is a flag? A flag is a special command we put alongside the main command, to alter the way the main command executes. We won’t go through every type of flags in this post, but let's take a look at the flags we need to delete a directory&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/ $ ls&lt;br&gt;
to_be_deleted&lt;br&gt;
~/ $ rm -r to_be_deleted/&lt;br&gt;
~/ $ ls&lt;br&gt;
~/t $ &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The -r flag tells the rm command to delete the folder and all its content. It works like a little safety net. Deleted files are usually not recoverable. Sometimes, you might have problems deleting files because of file permissions and such. There is another flag you can use, but must always be used with extreme caution&lt;/p&gt;

&lt;h2&gt;rm -rf&lt;/h2&gt;

&lt;p&gt;This command works the same as the previous command, except it will delete everything, no questions asked. If you were to write rm -rf *, you could, in a worst case scenario, do extreme damage to your system. I wanted to put this in a separate section because of this. Don’t be afraid to use the command, however. I use it all the time. Just be sure you know what you’re deleting, you probably won’t be able to recover the files.&lt;/p&gt;

&lt;h2&gt;cp&lt;/h2&gt;

&lt;p&gt;Sometimes, you want to copy stuff from one place, to another. The command cp, short for copy will do just that!&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/ $ ls&lt;br&gt;
file.py ingredients.txt not_so_secret_folder secret_folder&lt;br&gt;
~/ $ cp ingredients.txt not_so_secret_folder/&lt;br&gt;
~/ $ ls not_so_secret_folder/&lt;br&gt;
ingredients.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So, we list our files, and decide to move the ingredient.txt file into our not so secret folder. we do this by using the cp command, followed by the path, or folder we want to move the file to.&lt;/p&gt;

&lt;h2&gt;mv&lt;/h2&gt;

&lt;p&gt;Now, we copied the file to the wrong directory! Do we have to delete it, and copy the file to the proper directory? That sounds like a lot of work! Well, we could use the mv command, short for Move. The way mv is used, is pretty similar to the cp command. we use mv, followed by the file that we’re moving, and its destination.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/ $ mv not_so_secret_folder/ingredients.txt secret_folder/&lt;br&gt;
~/ $ ls not_so_secret_folder/&lt;br&gt;
~/ $ ls secret_folder/&lt;br&gt;
ingredients.txt nintendo_cheat_codes.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So we gave the command two paths. The first path is to where the file is. The second path is where we want to put the file.&lt;/p&gt;

&lt;h2&gt;Rename files and folders?&lt;/h2&gt;

&lt;p&gt;Would you believe me if I told you that there are no command for renaming files and folders? It’s actually true. There is an easy way of doing it, however it does not have its own command. We need to use the previous command, the mv. What the command actually does, is delete the file, and recreate it at the chosen path. We can take advantage of this, and use it to give the file a new name.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/ $ touch filr.txt&lt;br&gt;
~/ $ ls&lt;br&gt;
filr.txt&lt;br&gt;
~/ $ mv filr.txt file.txt&lt;br&gt;
~/$ ls&lt;br&gt;
file.txt&lt;br&gt;
~/ $ &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this example, we created a new file, but made a nasty typo. No problem! We just used the mv command to rename the file to its proper name!&lt;/p&gt;

&lt;h2&gt;Tab button in the terminal&lt;/h2&gt;

&lt;p&gt;To save time, the tab button is amazing. It can work as an auto complete, and also as a lightweight ls, when used with other commands. Say you want to copy a file to a new directory, but you suddenly forgot the exact name of the directory. Let’s discuss two ways of using the tab button&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/ $ cp &lt;br&gt;
file.py ingredients.txt not_so_secret_folder/ secret_folder/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;By writing cp followed by a space, and pressing tab twice, all the files in my current directory gets listed. Say we want to copy file.py into not_so_secret_folder. It was quite a long name, so we used the cp command to list the directory, and we start writing the name of the directory&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/ $ cp file.py no&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We press tab once&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/ $ cp file.py not_so_secret_folder/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and the rest of the directory name gets autocompleted. The tab button is super useful for quick navigation through the file system.&lt;/p&gt;

&lt;h2&gt;cat&lt;/h2&gt;

&lt;p&gt;Not the cat as in the purring kitty, but short for concatenate. This command can do multiple operations. One of the most useful ones, is printing a file content to the terminal, in one quick motion.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/ $ cat ingredients.txt &lt;br&gt;
1 tbsp of something&lt;br&gt;
2 cups of something else &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;we type cat, followed by the filename. The content of the filename gets printed to the terminal. This is a very quick way to peak inside the content of a file, without opening it up in any kind of software or text editor. (This is a side effect of the cat command. We won’t go over the concatenating part of the command in this blog post)&lt;/p&gt;

&lt;h2&gt;Text editors in terminal?&lt;/h2&gt;

&lt;p&gt;For editing text, there are a couple of editors that are pretty standard in every terminal you come across. Nano/Pico, and Vim/Vi. Nano is a simple text editor for manipulating and editing text. Vim is a workhorse (and my personal favorite) which, with some modifications, can do pretty much whatever you want it to do.&lt;/p&gt;

&lt;p&gt;If you’ve never used Vim before, Nano is a whole lot easier. It will show you its commands in the lower part of the program, and you can navigate the text by using the arrow keys.&lt;/p&gt;

&lt;p&gt;For Vim, it’s a whole different story. It comes with its own key bindings, it own way of doing.. Pretty much everything. I would definitely recommend learning it. However, once you learn how to use it, you will be annoyed that other writing softwares don’t use the same key bindings. I might write a beginner tutorial for Vim if anyone wants, however you’ll find tons of tutorials if you google it. Leave a comment if it sounds interesting.&lt;/p&gt;

&lt;h2&gt;Last words&lt;/h2&gt;

&lt;p&gt;These commands should get you up and running. There are a ton of other commands to pick up, but it should not be a problem once you learn the ones listed above.&lt;/p&gt;

&lt;p&gt;If you don’t use any special Windows software, or play high end games, you might just migrate over to a more secure, and stable OS. Not to mention, most of the Linux distros are free. And most of the software that runs on Linux is free.&lt;/p&gt;

&lt;p&gt;PS: If you like playing games, Steam supports a huge amount of games on Linux!&lt;/p&gt;

&lt;p&gt;In dire need of Microsoft Office suite? You can use Google Suite or Libre Office. You need Photoshop? What about the free photo editor Gimp! You’ll most likely find a free, amazing replacement for all your Windows software.&lt;/p&gt;

&lt;p&gt;Best Regards&lt;br&gt;
Stephan Bakkelund Valois&lt;/p&gt;

</description>
      <category>linux</category>
      <category>mac</category>
      <category>terminal</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
