<commit_before># Vim memo

## vimrc file

The vimrc file contains optional runtime configuration settings to initialize Vim when it starts.

<pre>
~/.vimrc
</pre>

http://vimdoc.sourceforge.net/htmldoc/usr_05.html#vimrc_example.vim

https://stackoverflow.com/questions/26708822/why-do-vim-experts-prefer-buffers-over-tabs

While in insert mode hit CTRL-R `{register}`.

For example, CTRL-R * will insert in the contents of the clipboard and CTRL-R " (the unnamed register) inserts the the last delete or yank.

`:set paste` This will prevent vim from re-tabbing your code. When done pasting, `:set nopaste` will return to the normal behavior.

It's also possible to toggle the mode with a single key, by adding something like set `pastetoggle=<F2>` to your `.vimrc`.

the `!` at the end of the command in vim toggles the command on and off.

`D` or its equivalent `d$` will delete the rest of the line and leave you in *command mode*. 
`C` or `c$` will delete the rest of the line and put you in *insert mode*, and new text will be appended to the line.


## Buffers

A buffer is a file loaded into memory for editing. All opened files are associated with a buffer. There are also buffers not associated with any file.

Vim buffers are identified using a name and a number. The name of the buffer is the name of the file associated with that buffer. The buffer number is a unique sequential number assigned by Vim. This buffer number will not change in a single Vim session. 

When you open a file using any of the Vim commands, a buffer is automatically created.

## Register

todo

## Commands

`<CR>` = Press the carriage return key also known as `<Enter>`.   

* `Esc` = Switch to Normal mode.
* `C-[` = Switch to Normal mode.
* `C-o` = Switch ot Insert Normal mode.
h3. Normal mode

### Movement

* `h`, `j`, `k`, `l` = move around.
* `W`, `w` = Move forward.
* `B`, `b` = Move backward.

* `$` = Move to end of line.
* `0` = Move to start of line.

* `gg` = Go to top of document.
* `G`  = Go to end of document.

* `^`  = jump to the first non-blank character of the line.
* `g_` = jump to the last non-blank character of the line.

* `H` = Go to top of screen.
* `M` = Go to middle of screen.
* `L` = Go to bottom of screen.

* `zz` = Redraws the screen with the current line in the middle of the window.
* `<C-e>` = Move screen up one line.
* `<C-y>` = Move screen down one line.

### Folding blocks

* `zc` close fold.
* `zo` open fold.
* `>i}` indent inner block.

### Indentation

* `zm` = increases the foldlevel by one.
* `zr` = decreases the foldlevel by one.
* `z Shift + o` opens all folds at the cursor.
* `z Shift + m` closes all open folds.

### Edit

* `x` deletes the character under the cursor.   
* `dd` also performs a deletion, but this one acts on the current line as a whole.   
* `>G` increases the indentation from the current line until the end of the file.   
* `.` The dot  command lets us repeat the last change.   

* `db` = Delete backward.
* `dw` = Delete forward.
* `daw` = Delete an Entire Word.

* `p` = paste test.
* `R` = Replace character.

* `<C-h>` = Delete back one *character*.
* `<C-w>` = Delete back one *word*.
* `<C-u>` = Delete back to *start of line*.

* `cW` = Change word.

### Search

* `f` = Find in line.
* `/`{pattern} = Find pattern.
* `n/N` = Jump to pattern match.
* `<C-a>` command will look ahead for a digit on the current line.

### Insert mode


### Visual mode 

* `shift` + `v` = Select using visual line.
* `viw` = visually select word under cursor.

#### Edit

* `c` = Changes word. Use with visual mode.

### Compound commands

* `C` = `c$`    = change (replace) to the end of the line.
* `s` = `sl`    = delete character and substitute text– and move cursor right.
* `I` = `^i`    = jump to the first non-blank character of the line– and insert before the cursor.
* `A` = `$a`    = jump to the end of the line– and insert (append) after the cursor.
* `o` = `A<CR>` = insert (append) at the end of the line– and ?
* `O` = `ko`    = move cursor up– and append (open) a new line below the current line.

### Misc

* `d2w` Invoke delete command and give `2w` as the motion. Deletes 2 words.




* `yy` = Yank the line.
* `<C-r><C-p>`{register} = Inserts text literally and fixes any unintended indentation
* To indent a curly-braces block, put your cursor on one of the curly braces and use `>%`.
* If you’re copying blocks of text around and need to align the indent of a block in its new location, use `]p` instead of just `p`. This aligns the pasted block with the surrounding text.


The expression register is addressed by the `=` symbol. From Insert mode we can access it by typing `<C-r>=`.

* `v` = Enable character wise visual mode
* `V` = Enable line wise visual mode
* `<C-v>` = Enable block wise visual mode.
* `gv` = Enable last visual selection.
* `o` “Go to other end of highlighted text”


When we use the dot command to repeat a Visual mode command, it acts on the same amount of text as was marked by the most recent visual selection.

The gv command is a useful little shortcut. It reselects the range of text that was last selected in Visual mode

As a general rule, we should prefer operator commands over their Visual mode equivalents when working through a repetitive set of changes.

sometimes we need to modify a range of text whose structure is difficult to trace. In these cases, Visual mode is the right tool for thejob.

We can use Visual-Block mode to insert text into several lines of text simultaneously.

* `vit` = select the inner contents of a tag
* `U` = converts the selected characters to uppercase
<commit_msg>Tidy up<commit_after># Vim memo

## vimrc file

The vimrc file contains optional runtime configuration settings to initialize Vim when it starts.

<pre>
~/.vimrc
</pre>

http://vimdoc.sourceforge.net/htmldoc/usr_05.html#vimrc_example.vim

https://stackoverflow.com/questions/26708822/why-do-vim-experts-prefer-buffers-over-tabs

While in insert mode hit CTRL-R `{register}`.

For example, CTRL-R * will insert in the contents of the clipboard and CTRL-R " (the unnamed register) inserts the the last delete or yank.

`:set paste` This will prevent vim from re-tabbing your code. When done pasting, `:set nopaste` will return to the normal behavior.

It's also possible to toggle the mode with a single key, by adding something like set `pastetoggle=<F2>` to your `.vimrc`.

the `!` at the end of the command in vim toggles the command on and off.

`D` or its equivalent `d$` will delete the rest of the line and leave you in *command mode*. 
`C` or `c$` will delete the rest of the line and put you in *insert mode*, and new text will be appended to the line.


## Buffers

A buffer is a file loaded into memory for editing. All opened files are associated with a buffer. There are also buffers not associated with any file.

Vim buffers are identified using a name and a number. The name of the buffer is the name of the file associated with that buffer. The buffer number is a unique sequential number assigned by Vim. This buffer number will not change in a single Vim session. 

When you open a file using any of the Vim commands, a buffer is automatically created.

## Register

todo

## Commands

`<CR>` = Press the carriage return key also known as `<Enter>`.   

* `Esc` = Switch to Normal mode.
* `C-[` = Switch to Normal mode.
* `C-o` = Switch ot Insert Normal mode.

## Normal mode

### Movement

#### Directional movment

* `h`, `j`, `k`, `l` = move around.
* `W`, `w` = Move forward.
* `B`, `b` = Move backward.

#### Go to

* `$` = Move to end of line.
* `0` = Move to start of line.
* `gg` = Go to top of document.
* `G`  = Go to end of document.
* `H` = Go to top of screen.
* `M` = Go to middle of screen.
* `L` = Go to bottom of screen.

#### Jump to

* `^`  = jump to the first non-blank character of the line.
* `g_` = jump to the last non-blank character of the line.

#### Scroll

* `zz` = Redraws the screen with the current line in the middle of the window.
* `<C-e>` = Move screen up one line.
* `<C-y>` = Move screen down one line.

### Folding blocks

* `zc` close fold.
* `zo` open fold.
* `>i}` indent inner block.
* `>G` increases the indentation from the current line until the end of the file.   

### Indentation

* `zm` = increases the foldlevel by one.
* `zr` = decreases the foldlevel by one.
* `z Shift + o` opens all folds at the cursor.
* `z Shift + m` closes all open folds.

### Edit

* `.` The dot  command lets us repeat the last change.   
* `cW` = Change word.

* `x` deletes the character under the cursor. 
* `dd` Deletes the current line. 
* `db` = Delete backward.
* `dw` = Delete forward.
* `daw` = Delete an Entire Word.

* `p` = paste text.
* `R` = Replace character.

* `<C-h>` = Delete back one *character*.
* `<C-w>` = Delete back one *word*.
* `<C-u>` = Delete back to *start of line*.

#### Search

* `f` = Find in line.
* `/`{pattern} = Find pattern.
* `n/N` = Jump to pattern match.
* `<C-a>` command will look ahead for a digit on the current line.

### Visual mode 

* `shift` + `v` = Select using visual line.
* `viw` = visually select word under cursor.

### Insert mode


#### Edit

* `c` = Changes word. Use with visual mode.

## Compound commands

* `C` = `c$`    = change (replace) to the end of the line.
* `s` = `sl`    = delete character and substitute text– and move cursor right.
* `I` = `^i`    = jump to the first non-blank character of the line– and insert before the cursor.
* `A` = `$a`    = jump to the end of the line– and insert (append) after the cursor.
* `o` = `A<CR>` = insert (append) at the end of the line– and ?
* `O` = `ko`    = move cursor up– and append (open) a new line below the current line.

### Misc

* `d2w` Invoke delete command and give `2w` as the motion. Deletes 2 words.
* `yy` = Yank the line.
* `<C-r><C-p>`{register} = Inserts text literally and fixes any unintended indentation
* To indent a curly-braces block, put your cursor on one of the curly braces and use `>%`.
* If you’re copying blocks of text around and need to align the indent of a block in its new location, use `]p` instead of just `p`. This aligns the pasted block with the surrounding text.


The expression register is addressed by the `=` symbol. From Insert mode we can access it by typing `<C-r>=`.

* `v` = Enable character wise visual mode
* `V` = Enable line wise visual mode
* `<C-v>` = Enable block wise visual mode.
* `gv` = Enable last visual selection.
* `o` “Go to other end of highlighted text”


When we use the dot command to repeat a Visual mode command, it acts on the same amount of text as was marked by the most recent visual selection.

The gv command is a useful little shortcut. It reselects the range of text that was last selected in Visual mode

As a general rule, we should prefer operator commands over their Visual mode equivalents when working through a repetitive set of changes.

sometimes we need to modify a range of text whose structure is difficult to trace. In these cases, Visual mode is the right tool for thejob.

We can use Visual-Block mode to insert text into several lines of text simultaneously.

* `vit` = select the inner contents of a tag
* `U` = converts the selected characters to uppercase

{'fraction_non_alphanumeric': 0.10681858643403952, 'fraction_numerical': 0.002759480149546021, 'mean_word_length': 3.4495049504950495, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 41, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '990417', 'n_tokens_mistral': 3588, 'n_tokens_neox': 3445, 'n_words': 1766}