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
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 .
Operator Precedence in Lua
As we all learned in algebra, it is not only important to understand how operators work, but also understand the order in which operators are applied. The order in which operators are applied is governed by their precedence and their association . Lua operators have the following precedence, ordered from highest to lowest priority, and association: Group Operators Association Exponentiation ^ Right Unary Operators not # - ~ Left Arithmetic * / % Left Arithmetic + - Left Concatenation .. Right Bitwise & Left Bitwise ~ Left Bitwise | Left Relational < > <= >= ~= == Left Logical and Left Logical or Left As with algebra, parentheses can be used to override the order of precedence of an expression.