Contents
Preface
For solving the tasks given by the lecture usually the usage of an integrated development environment (IDE) is overkill. This page presents a few simpler editors focusing on vim which is used by Prof. Dr. Hannah Bast.
Vim
Vim is a comandline based editor with explicit modes. In insert mode text can be written as in any other editor. However in command mode operations like search, write file or close can be performed.
The vim of Prof. Dr. Hannah Bast is personalized with a version from 2010 downloadable. This file has to be placed in the home-directory as .vimrc on linux and _vimrc in windows.
Changing modes and help
ESC exits insert mode and enters command mode. If already in command mode nothing happens.
i (in command mode) enters insert mode.
:help (in command mode) displays a help file inside vim.
Useful commands
File and generic commands |
|
:e <filename> |
Open <filename> |
:w |
Write current file |
:w <filename> |
Write current file as <filename> |
:q |
Exit the editor if only one file is open. If the current file is modified this will fail with an error message. If multiple files are open, only the active one will be closed. |
:wq / :x |
Combined write and quit, alternatively exit. |
:q! |
Close the file without saving changes. |
:sp <file> |
Horizontal split, opening an additional file below the current file. |
:tabnew <file> |
Opens <file> as a browser like tab. |
Basic editing commands |
|
yy |
Copies current line |
nyy |
Copy n lines |
p / P |
Past previously copied line(s) below / above |
dd |
Delete current line |
ndd |
Delete n lines |
dw |
Delete until the next word |
cw |
Delete until next word and change mode to insert mode |
o / O |
Create a new line below / above and change to insert mode |
Viewcommands |
|
:v |
Change to visual mode |
:se nu / :set number |
Show line numbers |
:se nonu / :set nonumber |
Hide line numbers |
:so $VIMRUNTIME/syntax/cpp.vim |
C++ syntax highlighting |
Ctrl+W <Arrow up> |
Switch to pane above |
Ctrl-K |
Switch to pane above and maximize it (only available with the .vimrc) |
Ctrl+W <Arrow down> |
Switch to pane below |
Ctrl-M |
Switch to pane below and maximize it (only available with the .vimrc) |
Ctrl+W _ |
Maximize current pane |
F4 |
Switch between *.h und *.cpp file. File has to be saved (only available with the .vimrc) |
Ctrl-Page Up/Down |
Switch between browser style tabs |