Difference between revisions of "VIM"
(Created page with '==Syntax Highlighting== Inside VI type the command below. :syntax on') |
|||
(22 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
:syntax on | :syntax on | ||
+ | |||
+ | Maybe | ||
+ | |||
+ | :syn on | ||
+ | |||
+ | == Bottom Page == | ||
+ | This goes to the bottom of the page. | ||
+ | G | ||
+ | |||
+ | == Bookmarks == | ||
+ | To bookmark a position press m and then a letter. Use capital letter for Global or multiple files. | ||
+ | ma | ||
+ | |||
+ | To go to the bookmark press ` and then letter marking you want to go to. | ||
+ | `a | ||
+ | |||
+ | To see all your bookmarks. | ||
+ | :marks | ||
+ | |||
+ | To to last edit location. | ||
+ | `. | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | == Record == | ||
+ | To record a set of keys press q and then a letter to record to. | ||
+ | qa | ||
+ | |||
+ | To play back the recording press @ and then letter marking you want to play back. | ||
+ | @a | ||
+ | |||
+ | == Copy & Paste == | ||
+ | To yank to a registered key | ||
+ | " + {key} + y | ||
+ | |||
+ | To paste from a registered key. | ||
+ | " + {key} + p | ||
+ | |||
+ | == Windows == | ||
+ | '''Switch''' between windows. The arrow key or direction key you want to go to. | ||
+ | ctrl+w {arrow key} or {h,j,k,l} | ||
+ | |||
+ | Opens a new vertical split | ||
+ | CTRL+w, v | ||
+ | |||
+ | Opens a new horizontal split | ||
+ | CTRL+w, s | ||
+ | |||
+ | Closes a window but keeps the buffer | ||
+ | CTRL+w, c | ||
+ | |||
+ | Closes other windows, keeps the active window only | ||
+ | CTRL+w, o | ||
+ | |||
+ | Moves the current window to the right | ||
+ | CTRL+w, r | ||
+ | |||
+ | Makes all splits equal size | ||
+ | CTRL+w, = | ||
+ | |||
+ | == Show Whitespace == | ||
+ | |||
+ | This will show all whitespace char | ||
+ | set list | ||
+ | |||
+ | You can also show only select char. | ||
+ | :set listchars=eol:$,tab:>-,trail:~ | ||
+ | |||
+ | == Spelling == | ||
+ | To turn spell checker on. | ||
+ | :set spell spelllang=en_us | ||
+ | |||
+ | To turn spell checker off. | ||
+ | :set nospell | ||
+ | |||
+ | To move between misspelled words. | ||
+ | ]s and [s | ||
+ | |||
+ | To get misspelled recommendations, move in misspelled word and press. | ||
+ | z= | ||
+ | |||
+ | To add word to dictionary. | ||
+ | zg | ||
+ | |||
+ | To mark a word as incorrect | ||
+ | zw | ||
+ | |||
+ | |||
+ | == Autocomplete == | ||
+ | This autocomplete tries to match word already in the document. | ||
+ | ctl+n or ctl+p | ||
+ | |||
+ | == Netrw == | ||
+ | Open as a left window. | ||
+ | :Lexplore or :Lex | ||
+ | |||
+ | Open as a new tab. | ||
+ | :tabe . | ||
+ | |||
+ | Open file in new tab when in Netrw. | ||
+ | t | ||
+ | |||
+ | Create new file. | ||
+ | % | ||
+ | |||
+ | Create new directory. | ||
+ | d | ||
+ | |||
+ | Delete file or directory. | ||
+ | D | ||
+ | |||
+ | == Terminal == | ||
+ | You can open a new terminal by typing. | ||
+ | :terminal | ||
+ | |||
+ | You can enter `normal` mode. | ||
+ | ctrl-\ ctrl-n | ||
+ | |||
+ | Exit terminal mode | ||
+ | ctrl-d | ||
+ | |||
+ | == Pipe in data from console == | ||
+ | To pipe in data from the command line use the following | ||
+ | :%!{command} | ||
+ | |||
+ | or | ||
+ | |||
+ | If you in the terminal and want the output to go into vim. | ||
+ | ls | vim - | ||
+ | |||
+ | == Column Editing == | ||
+ | Column editing is editing a bunch of lines at once. | ||
+ | |||
+ | ctrl-v - start highlight of columns. | ||
+ | h,j,k,l - to select the columns and/or rows | ||
+ | shift-i - to go to insert mode. | ||
+ | |||
+ | == Highlight blocks == | ||
+ | To quick highlight blocks of code with in { or [ | ||
+ | |||
+ | Move the curser inside the block, and type the following. | ||
+ | vi[ | ||
+ | or | ||
+ | vi{ | ||
+ | |||
+ | == Edit in VIM == | ||
+ | To bring a command line in to VIM for editing | ||
+ | ctrl+x ctrl+e | ||
+ | |||
+ | == Switch bash to use VIM == | ||
+ | This will allow the terminal to use vim keys. | ||
+ | set -o vi | ||
+ | |||
+ | == Diff == | ||
+ | The following key combinations will show the diff between two copied registries. | ||
+ | |||
+ | :tabnew // Create a new tab. | ||
+ | " -> a -> p // Paste the text from registry 'a' | ||
+ | leftabove vnew diff1. // create a side window called diff1 | ||
+ | |||
+ | ctr+w ->> // switch windows | ||
+ | |||
+ | " -> b -> p // paste the text from registry 'b' | ||
+ | ctr+w <<- // Switch windows again | ||
+ | :diffthis // diff the two windows |
Latest revision as of 15:53, 9 July 2024
Contents
Syntax Highlighting
Inside VI type the command below.
:syntax on
Maybe
:syn on
Bottom Page
This goes to the bottom of the page.
G
Bookmarks
To bookmark a position press m and then a letter. Use capital letter for Global or multiple files.
ma
To go to the bookmark press ` and then letter marking you want to go to.
`a
To see all your bookmarks.
:marks
To to last edit location.
`.
Record
To record a set of keys press q and then a letter to record to.
qa
To play back the recording press @ and then letter marking you want to play back.
@a
Copy & Paste
To yank to a registered key
" + {key} + y
To paste from a registered key.
" + {key} + p
Windows
Switch between windows. The arrow key or direction key you want to go to.
ctrl+w {arrow key} or {h,j,k,l}
Opens a new vertical split
CTRL+w, v
Opens a new horizontal split
CTRL+w, s
Closes a window but keeps the buffer
CTRL+w, c
Closes other windows, keeps the active window only
CTRL+w, o
Moves the current window to the right
CTRL+w, r
Makes all splits equal size
CTRL+w, =
Show Whitespace
This will show all whitespace char
set list
You can also show only select char.
:set listchars=eol:$,tab:>-,trail:~
Spelling
To turn spell checker on.
:set spell spelllang=en_us
To turn spell checker off.
:set nospell
To move between misspelled words.
]s and [s
To get misspelled recommendations, move in misspelled word and press.
z=
To add word to dictionary.
zg
To mark a word as incorrect
zw
Autocomplete
This autocomplete tries to match word already in the document.
ctl+n or ctl+p
Netrw
Open as a left window.
:Lexplore or :Lex
Open as a new tab.
:tabe .
Open file in new tab when in Netrw.
t
Create new file.
%
Create new directory.
d
Delete file or directory.
D
Terminal
You can open a new terminal by typing.
:terminal
You can enter `normal` mode.
ctrl-\ ctrl-n
Exit terminal mode
ctrl-d
Pipe in data from console
To pipe in data from the command line use the following
:%!{command}
or
If you in the terminal and want the output to go into vim.
ls | vim -
Column Editing
Column editing is editing a bunch of lines at once.
ctrl-v - start highlight of columns. h,j,k,l - to select the columns and/or rows shift-i - to go to insert mode.
Highlight blocks
To quick highlight blocks of code with in { or [
Move the curser inside the block, and type the following.
vi[
or
vi{
Edit in VIM
To bring a command line in to VIM for editing
ctrl+x ctrl+e
Switch bash to use VIM
This will allow the terminal to use vim keys.
set -o vi
Diff
The following key combinations will show the diff between two copied registries.
:tabnew // Create a new tab. " -> a -> p // Paste the text from registry 'a' leftabove vnew diff1. // create a side window called diff1 ctr+w ->> // switch windows " -> b -> p // paste the text from registry 'b' ctr+w <<- // Switch windows again :diffthis // diff the two windows