HTML Elements
HTML entities are used to display "special" characters in HTML, which are characters that: can be misinterpreted as HTML markup, are invisible characters such as non-breaking spaces, and are difficult to type with a standard keyboard. HTML entities can be referenced by name or number, in either decimal or hexadecimal notation. Each is shown in the table below, and can be copied by clicking on the desired entity.
HTML Elements
HTML entities are used to display "special" characters in HTML, which are characters that: can be misinterpreted as HTML markup, are invisible characters such as non-breaking spaces, and are difficult to type with a standard keyboard. HTML entities can be referenced by name or number, in either decimal or hexadecimal notation. Each is shown in the table below, and can be copied by clicking on the desired entity.
ASCII Codes
ASCII is an acronym for American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Although ASCII has been extended and superseded by Unicode , ASCII codes are still pervasive in computing, particularly when working in the terminal . The following table summarizes the ASCII codes expressed in several convenient bases, and additionally provides the "carat escaped" value as is often seen in neovim .
Back-References in Neovim Patterns
In the previous section we introduced non-capturing group as a way to group sub-patterns into atoms so that they can be used in alternation and with quantifiers . In this section we introduce capturing groups, which have all of the same behaviors and uses as non-capturing groups, but additionally maintain a reference to (i.e. capture) the matched text so that it can be used later. As an example, suppose we need to write a pattern that matches both single and double-quoted text in a document. A reasonable pattern to achieve this might be: ["'][a-z -]["'] We will use the following buffer to test it: Initial Conditions line of text line with "double-quoted" text line of text line with 'single-quoted' text line of text some "double-quoted text with 'single-quoted' text inside" COMMAND Top 1:1 /[\"'][a-z -]\+[\"'] Lets run it. Pattern without back-reference line of text line with "double-quoted" text line of text line with 'single-quoted' text line of text some "double-quoted text with 'single-quoted' text inside" NORMAL 29% 2:11 Hmm, thats not what we wanted. So what happened? In order to accommodate both single and double quotes we included them both in the pattern. But, since either type of quotation is acceptable, Vim happily matched inconsistent quotation marks. What we need is for the pattern to match the same type of quotation mark. This can be achieved using back-references, so let's update our pattern. To use back-references, first define one or more capturing groups in the pattern, then add the back-reference: \(["']\)[a-z -]\1 In this example, the back-reference "\1" is used to refer to the capturing group. Since there is only one capturing group, the back-reference \1 refers to it. Patterns can have multiple capturing groups, and those groups can also intersect. To identify which number to use for a back-reference, start from the left side of the pattern and count the opening-parentheses until you reach the group in question, then use that number as the reference. In addition, the entire matched portion of the string can be returned using the "\0" back-reference. Lets now try our updated pattern: Pattern with back-reference line of text line with "double quoted" text line of text line with 'single quoted' text line of text some "double quoted text with 'single quoted' text inside" NORMAL 29% 2:11 Now, that is a bit closer to the result we were looking for, but we should allow nested comments. We can add this by making one more change: Alternate pattern with back-reference line of text line with "double quoted" text line of text line with 'single quoted' text line of text some "double quoted text with 'single quoted' text inside" NORMAL 29% 2:11 So how does the back-reference work? When a capturing group matches an atom, it retains a reference to that atom. When a back-reference is included in the pattern, then the previously-matched content is inserted in its place before the back-reference matches. Therefore, if a double-quote matched in the capturing group, then the back-reference is looking for a double-quote. This explains the difference between our second and third patterns. Vim initially matched the double-quote, but because the pattern did not allow quotations in the matched string, the string starting with the double quote no longer matched. Vim started a new match with the single quote, which ended with the closing single quote. With the third patter, the first match (starting with the double-quote) extended all the way to the closing double-quote, which was our final result. This example showed how back-references can be used in when searching , but back-references are also very useful when searching and replacing in order to use the matched text in the replacement. The replacing section contains information about this.
Simple Neovim Ranges
commands that run in command-line mode often accept a range, which specifies which line(s) of the current buffer are to be used as input for the command . The general pattern for specifying a range is: :[from],[to]{command} where from and to specify the start and end of the range, respectively, and {command} is the name of the command to be executed on those lines. For example, to :yank lines 2 through 5 to register a, one could specify: :2,5yank a Step 1 Prior to Execution "When someone is searching," said Siddhartha, "then it might easily happen that the only thing his eyes still see is that what he searches for, that he is unable to find anything, to let anything enter his mind, because he always thinks of nothing but the object of his search, because he has a goal, because he is obsessed by the goal. Searching means: having a goal. But finding means: being free, being open, having no goal. You, oh venerable one, are perhaps indeed a searcher, because, striving for your goal, there are many things you don't see, which are directly in front of your eyes." COMMAND 40% 4:1 :2,5yank a Step 2 After Execution "When someone is searching," said Siddhartha, "then it might easily happen that the only thing his eyes still see is that what he searches for, that he is unable to find anything, to let anything enter his mind, because he always thinks of nothing but the object of his search, because he has a goal, because he is obsessed by the goal. Searching means: having a goal. But finding means: being free, being open, having no goal. You, oh venerable one, are perhaps indeed a searcher, because, striving for your goal, there are many things you don't see, which are directly in front of your eyes." NORMAL 40% 4:1 4 lines yanked into "a Step 3 Confirm Register Content "When someone is searching," said Siddhartha, "then it might easily happen that the only thing his eyes still see is that what he searches for, that he is unable to find anything, to let anything enter his mind, because he always thinks of nothing but the object of his search, because he has a goal, because he is obsessed by the goal. Searching means: having a goal. But finding means: being free, being open, having no goal. You, oh venerable one, are perhaps indeed a searcher, because, striving for your goal, there are many things you don't see, which are directly in front of your eyes." NORMAL 40% 4:1 :reg a Type Name Content l "a happen that the only thing his eyes still see is that what he searche Let's take a look at what happened. Step 1 shows the starting cursor location, and the command to be executed (prior to execution). Step 2 indicates that 4 lines were yanked (2, 3, 4, and 5), and Step 3 confirms that the yanked range started with line 2 (as expected). We will use this format to show which commands are executed and the results throughout this chapter. One of the powerful features of ranges is that from and to can be specified as expressions that are evaluated when the command is executed. There are several types of range expressions available, which we will review in the following sections. We already saw the most simple case, where from and to are defined as static line numbers. The next set of range expressions evaluate to dynamically specify lines in the buffer : Expression Meaning $ the last line of the buffer . the current line These expressions can be used directly in place of line numbers in the range. For example, the following range expression defines a range that contains all lines in the buffer : :1,$ Step 1 Prior to Execution "When someone is searching," said Siddhartha, "then it might easily happen that the only thing his eyes still see is that what he searches for, that he is unable to find anything, to let anything enter his mind, because he always thinks of nothing but the object of his search, because he has a goal, because he is obsessed by the goal. Searching means: having a goal. But finding means: being free, being open, having no goal. You, oh venerable one, are perhaps indeed a searcher, because, striving for your goal, there are many things you don't see, which are directly in front of your eyes." COMMAND 40% 4:1 :1,$yank b Step 2 After Execution "When someone is searching," said Siddhartha, "then it might easily happen that the only thing his eyes still see is that what he searches for, that he is unable to find anything, to let anything enter his mind, because he always thinks of nothing but the object of his search, because he has a goal, because he is obsessed by the goal. Searching means: having a goal. But finding means: being free, being open, having no goal. You, oh venerable one, are perhaps indeed a searcher, because, striving for your goal, there are many things you don't see, which are directly in front of your eyes." NORMAL 40% 4:1 9 lines yanked into "b Step 3 Confirm Register Content "When someone is searching," said Siddhartha, "then it might easily happen that the only thing his eyes still see is that what he searches for, that he is unable to find anything, to let anything enter his mind, because he always thinks of nothing but the object of his search, because he has a goal, because he is obsessed by the goal. Searching means: having a goal. But finding means: being free, being open, having no goal. You, oh venerable one, are perhaps indeed a searcher, because, striving for your goal, there are many things you don't see, which are directly in front of your eyes." NORMAL 40% 4:1 :reg b Type Name Content l "b "When someone is searching," said Siddhartha, "then it might easily This range is so common that there is an expression for that too, %. For example, to yank the entire buffer into register a, the following are equivalent: :1,$yank a :%yank a which is confirmed by comparing to the previous example: Step 1 Prior to Execution "When someone is searching," said Siddhartha, "then it might easily happen that the only thing his eyes still see is that what he searches for, that he is unable to find anything, to let anything enter his mind, because he always thinks of nothing but the object of his search, because he has a goal, because he is obsessed by the goal. Searching means: having a goal. But finding means: being free, being open, having no goal. You, oh venerable one, are perhaps indeed a searcher, because, striving for your goal, there are many things you don't see, which are directly in front of your eyes." COMMAND 40% 4:1 :%yank c Step 2 After Execution "When someone is searching," said Siddhartha, "then it might easily happen that the only thing his eyes still see is that what he searches for, that he is unable to find anything, to let anything enter his mind, because he always thinks of nothing but the object of his search, because he has a goal, because he is obsessed by the goal. Searching means: having a goal. But finding means: being free, being open, having no goal. You, oh venerable one, are perhaps indeed a searcher, because, striving for your goal, there are many things you don't see, which are directly in front of your eyes." NORMAL 40% 4:1 9 lines yanked into "c Step 3 Confirm Register Content "When someone is searching," said Siddhartha, "then it might easily happen that the only thing his eyes still see is that what he searches for, that he is unable to find anything, to let anything enter his mind, because he always thinks of nothing but the object of his search, because he has a goal, because he is obsessed by the goal. Searching means: having a goal. But finding means: being free, being open, having no goal. You, oh venerable one, are perhaps indeed a searcher, because, striving for your goal, there are many things you don't see, which are directly in front of your eyes." NORMAL 40% 4:1 :reg c Type Name Content l "c "When someone is searching," said Siddhartha, "then it might easily
What is a Terminal?
Much of the terminology used when discussing modern terminals comes from history, which can make understanding terminals seem more confusing than it should be. A small amount history can help provide some background information to help some of the concepts be more relatable. Early computers were comprised of multiple refrigerator-sized cabinets, each of which performed one of the basic tasks of the system. For example, one cabinet would contain the "central processing unit " (CPU), while other cabinets held tape drives , disk drives , punched-card readers , a line printer , and any other peripherals that were available to the computer. The user-interface to these computers consisted of a keyboard and some means of displaying the output from the computer, such as a sequence of light bulbs or later a Cathode-ray Tube (CRT) display , connected to the computer via cables. The user-interface was typically arranged into a "console ", where the operator could sit and interact with the computer. Since the user-interface represented the point at which electrical signals "enter" and "exit" the network, the user-interfaces themselves became known as "terminals ". Standardization As often happens in technology development, there were initially a wide range of competing technologies, but over time market forces and economies of scale led these competing technologies to converge towards standardization around a handful of those technologies, the names of which have become much of the jargon that surrounds the terminal today. Early terminals were electro-mechanical "Teletype writers", generally shortened to "TTY ", which is a term still used today when interacting with the terminal. As with a modern keyboard, each key on the TTY represented a human-readable character such as a letter, number, punctuation, etc. As the user would press a key to input data into the computer, each key would be "encoded " into a sequence of 8 1s and 0s called bytes , which could be understood by the computer. These bytes were sent over the cable to the CPU, which performed the requested operations, then the resulting byte(s) were transmitted back to the terminal where they were "decoded" back into characters for human-consumption. The rules used for encoding and decoding each character eventually became the ASCII standard. Despite the benefits of standardization, the ASCII standard was written to support US English, which led to several extensions in order to support other languages, which eventually led to the UTF-8 standard which unified the various extensions into a single encoding that is broadly in use today. Over time display technologies evolved which led to the introduction of "video terminals" (VT) which allowed text and other graphical information to be displayed on a screen. Some of the most popular video terminals were the VT100 and later VT200 series, which introduced support for the ANSI escape codes that have become standards that are still in use today. Emulation As microprocessor technology advanced and the cost of memory and other peripherals dropped, terminals began to handle increasingly-advanced operations, which led to the introduction of "intelligent terminals ", which differentiated them from the "dumb terminals" they replaced. In order to make the newer terminals "backward compatible " with existing software, these terminals included hardware to "emulate " the older devices. Over time the emulation functions were implemented in software, which eventually led to the introduction of fully-software "terminal emulators " that could offer features that would have been difficult to impossible to implement in hardware, such as command-line completion and syntax highlighting . With the introduction of terminal emulators, "the terminal" became a software window that is opened in order to gain access to the operating system . The software that provides this access is called "the shell", which is the subject of the next section.
Getting Help in Neovim
Neovim includes an extensive help system, which provides a significant amount of detail about virtually any vim-related topic. To open the help system, from Normal mode enter the command : :help Which splits the current window and displays a buffer containing the main help page. We will review splits shortly in the windows chapter. navigate the help window as you would any buffer , for example using j , k , etc. Help for a specific topic The help contents for a specific topic or command by adding the topic or command when invoking the help system. For example, to review the documentation for the help system itself: :help help Following links Help contents often contain links to other help topics. To review the linked content, move the cursor over the link and type C-] . Changing topics Once in the help system you can manually jump to other topics using the tag command: :tag [topic] where topic refers to the help topic you want to jump to. Returning to topics Return to the previous help topic by invoking C-T . Exiting the help window Exit the help window and return to the original window by typing C-W c or :quit .