Vim text editor: Difference between revisions

Jump to navigation Jump to search
409 bytes added ,  Yesterday at 00:01
Add navigation section
No edit summary
 
(Add navigation section)
 
Line 8: Line 8:
to start vim and edit a file (new or existing)
to start vim and edit a file (new or existing)
     vim file_name
     vim file_name
to start vim and open a new file (
to start vim in NetRW (file tree)
You can give the stuff you typed in a name when later you save it as a file.)
     vim .
     vim


to exit vim and save your document first press '''ESC''' then
to write your changes
    :w
to quit vim
    :q
you can also combine these
     :wq
     :wq
to exit, saving as a new filename again press '''ESC'' then
to write to a file
     :wq <filename>
     :w <file>
to exit without saving (force quit) press '''ESC''' then
to quit without saving
     :q!
     :q!
to enter NetRW
    :Ex


==='''Editing'''=== When in vim you will notice that you cannot enter any text, this is because you are in the command mode of the editor, to enter the insert mode press 'i' or 'insert'. To return to the command mode hit 'ESC'
==='''Normal Mode'''===
==='''Deleting'''===
Normal mode is the default mode you are in when you enter Vim. This is the mode you will spend most of your time in, as it's used to navigate around your file. To go back to normal mode hit 'ESC' on your keyboard.
OK, the 'delete' key always works, as does the 'backspace'. However, vim has another deletion method through the command mode that doesn't require entering the insert mode.


1. move the cursor to the character you want to delete
===='''Navigation'''====
To navigate in Vim you primarily use the
    '''I''' '''J''' '''K''' '''L'''
keys, to navigate to the
    '''left''' '''down''' '''up''' '''right'''
directions respectively.
 
For example,
    '''J'''
will bring your cursor 1 line down!
You can also add a number to vim commands to do them that number of times.
 
For example,
    '''5J'''
will bring your cursor 5 lines down!
 
There are also other keys to move your cursor such as:
    '''W'''
which moves your cursor forward one word,
    '''B'''
which moves your cursor back one word,
    '''G'''
which moves your cursor to the final line of the file,
    '''gg'''
which moves your cursor to the first line of the file, and
    '''f<character>'''
which moves your cursor to the next instance of <character> on the current line!


2. press x , this character disappears


==='''Searching for Words'''===
==='''Searching for Words'''===
1

edit

Navigation menu