To open a file in vim, just type
vim <filename>
To save and exit files, you must be in command mode (click esc). You must type the :
before each of the lettered commands.
- :q exit editor
- :w save changes
- :wq save changes and exit editor
- :q! force quit editor without saving changes
- h move the cursor to the left
- l move it to the right
- k move up
- j move down
- or use the arrow keys
- **^** move the cursor to the begnning of the line - **$** move the cursor to the end of the line - **gg** move the cursor to the beginning of file - **G** move the cursor to the end of the file
- This will allow you to type and make changes just like you would in gedit or similar
- i insert mode
To exit editing mode, press
ESC
key.
- dd will delete current line
- n dd will delete n lines including and below current line
- dw will delete the word to the right of the cursor
- n dw will delete n words to the right of the cursor
- x will delete letter highlighted by the cursor
- :n go to the nth line in the file.
[abc]
- matches the single characters a,b,c
[a-z]
- matches the letters in range a-z
[A-Za-z]
- matches the letters in range a-z or A-Z
[A-Za-z0-9]
- matches any letter or number
.
- any single character
[abc]*
- zero or more of a,b,c (any combination)
[abc]+
- one or more of a,b,c (any combination)
(a|b|c)
- a, b, or c
Ensure a domain ends with .com or .org
[A-Za-z0-9]+\.(com|org)
[A-Za-z0-9]+ - one or more letters or numbers
\. - the symbol '.'. Must escape it since in regex it has an alternative meaning
(com|org) - domain must end in com or org
Validate Java Function Name
Regex: [A-Za-z][A-Za-z0-9_]*
[A-Za-z] - first character of function MUST be a letter
[A-Za-z0-9_]* - the characters after the first (if they exist) can be a letter, number, or underscore.