What is GG doing in Vim


Vim is a versatile editor that can be expanded using macros. It offers / SyntaxHighlighting and a graphical user interface based on GTK. This is called gvim. The KDE version was called Kvim, but it was mostly buggy and has not been further developed for a few years. The developers are now putting the work into a project called Kyzis. Otherwise you can also use the GTK graphical user interface under KDE.

The Vim is a clone of the original vi.

Homepage: http://www.vim.org/

License: Vim license

There is also a very good online book (s) in PDF format about Vim, see there in particular the programming tips starting on page 67.

  • Call:
  • Change of mode in edit mode:
    • - Switch on insert mode (text insertion mode). Important: do not enter any text beforehand!

    • - Leave insert or replace mode, back to command mode

  • in command mode:
    • - to save

    • - quit (if nothing has been changed or has already been saved)

    • - exit without saving, discard changes

So much for survival with Vim.

  • Call:
    • to jump directly to line 123

  • in command mode:
    • - Undo. Undo last change.

    • - Switch to insert mode ("insert"), the insertion point is in front of the current position

    • - Switch to insert mode ("add"), the insertion point is after the current position

    • - Switch to insert mode ("Add"), the insertion point is at the end of the current line

    • - Switch to overwrite mode ("Replace")

    • - Jump to the end of the current file ("goto")

    • - Jump to the beginning of the current file

    • or - Go to line n

    • - Delete ("delete"). Application see below

    • - Replace ("change"). Application see below

    • - Copy into the text buffer ("yank"). Application see below

    • - Insert text buffer after the current line ("put")

    • - Insert text buffer in front of the current line ("Put")

    • - Split window vertically

    • - Cursor in the next window

    • - Cursor in the previous window

    • looking forward

    • search backwards

  • Commands with "to details":
    • Clear

    • Replace

    • Copy to buffer

  • "To-details" explained using the example of d (delete). The same applies to c (replace) y (copy to buffer) ...:
    • - 3 times deletion of the current line (command 'd' is repeated)

    • - delete 4 characters (after 'd' there is a space '')

    • - Delete 2 words ('w')

    • - Delete to the end of the line

    • - Delete to the beginning of the line

    • - Delete up to the text "abc" ("abc" is not deleted)

    • - Delete up to the '=' character (only within the current line). '=' is also deleted. If there is no '=' in the line, nothing happens

    • - Delete until the end of the file

    • - Delete up to the beginning of the file

  • Single character commands:
    • - delete the current character

    • - position on the character x (to the right) (x can be any character)

    • - position on the character x (to the left) (x can be any character)

    • - replace the current character with x (x can be any character)

  • Positioning
    • - (digit '0'): go to the beginning of the line

    • - Repeat the last search ("next")

    • - Repeat the last search backwards

  • Ex orders
    • - Split window horizontally

    • - Split window vertically

    • - opens the help

    • - opens the help for

    • - shows all commands that begin with a colon

    • - Save and exit

    • - jump to line 123

    • or - jump to the end of the file

    • search and replace throughout text

    • Search the current line and replace on the first match

    • Find in the current row and replace on all matches

    In general, all commands can be preceded by a range.
  • dd
    • Delete the current line
  • yy
    • Bring the current line into the copy buffer
  • 123G
  • Indenting or dedenting blocks:
    • V.
    • (cursor down a few times to mark the block)
    • > or <

  • ggg? G
    • A gg jumps to the head of the file. From then to the end, the file is encrypted with Rot13.

    • Line 1 to the last line: replace hello with hello, as often as you like per line.
    • "%" is synonymous with "1, $"
    • Replace Hello with Hello from brand a to brand b
    • Current line up to 3 lines further: Replace 1 with 2, only the first time in the line.
    • Replace Robby with Robert in every line that starts with Name: several times.

Find and replace in / etc / fstab

* all mounts should be supplemented with the option "noatime":

  • Call the editor:

  • replace all "defaults" with "defaults, noatime:
      • %: pay attention to all lines
      • s / defaults / defaults, noatime /: replace "defaults" with "defaults, noatime"
  • Disable (comment out) all NFS mounts
      • / nfs /: handle all lines that contain "nfs"
      • : replaces the beginning of the line ("^") with "#"

  • Correct the IP address of the NAS
      • Search for the text "cifs". The line "# // / media / fritz cifs ..." is jumped to, that is the wrong one (because of the comment)
      • "n" (like "next") jumps to the next position with "cifs", it is found: "// / media / fritz cifs ..."
      • with the 0 (the number 0) you jump to the beginning of the line
      • the cursor jumps to the second "2", i.e. the 3rd decimal number of the IP
      • cw replaces a word, so here the "2" with the value "44"
    • The line is now // / media / fritz cifs ... "

With you get an introduction to and in Vim.

  • To switch on in the editor or in the.

  • Select syntax using as an example for HTML.

  • Own syntax files come in ~ / .vim / syntax /.
  • An example of self-made syntax highlighting can be found on ExternalEdit.

Can be controlled via the options and.

For example, if you want tabs to be displayed only 4 spaces wide, you should set and possibly also set so that it is correctly indented in the case of etc.

If you want to use X11 Copy & Paste to take over content e.g. from a web browser, you should switch off autoindent beforehand using - then you don't have to remove the otherwise resulting "staircase pattern".

  1. u The undo function is extremely important. It's also nice that, unlike vi, vim can undo more than one change.

  2. <STRG-p> or. <STRG-n> (i.e. CTRL key and p or n at the same time) I mainly edit C / C ++ code and often 10 lines later I no longer know whether I have named the variable vrglStr, vrglstring, vrgl_string or vrgl_String. So go back the lines in the code, look up, etc.? NO, easier: I type as far as I can still remember ) and then - now Vim searches backwards for words that start with vrgl. The first hit is displayed and I can just keep writing. If there were more words that begin with vrgl, they are displayed in the order in which I am, I just have to press again. The p stands for Previous. If you tried the whole thing with , you will see that n stands for Next, so the search direction is simply reversed.

  3. # and * If the cursor is over a word and you press #, then for Vim it means "search backwards for this word and bring the cursor there". * does the same, only the search direction is forward.

  4. % If the cursor is over a bracket,% jumps to the corresponding opening or closing bracket. This also works with the vi. With the following script http://www.vim.org/scripts/script.php?script_id=39 this also works with languages ‚Äč‚Äčthat have different control structures, such as TeX or XML. So if you are over a day and press% vim jumps to the corresponding counterpart.

  5. :% s / windows / linux / g Search function: search windows, replace with linux, g stands for all occurrences in one line,% for the entire text

  6. v, V. and ctrl-V Characters, lines and block-by-block visual marking. After marking, text can be inserted with I. c changes the selected text, x or d deletes it and> and

  7. = Serves for the correct alignment of program texts. Just try =% or ==.

  8. : noh Turns off the highlighting of search results, which can be very irritating with short search strings. Alternatively, you can also search for a character string that definitely does not exist (e.g. / cdnnsdcjsd).

These are the configuration files for the Vim. When starting the Gvim, the ~ / .gvimrc is also sourced. If there are no rc's in the home directory, the defaults are run through. With Debian, they are in / etc / vim in the Vim installation directory, which is usually / usr / share / vim. Great things can now be accommodated in the ~ / .vimrc (here an example) and ~ / .gvimrc, such as the preferred color scheme etc.

Vim supports plugins, system-wide or user-specific. There are now over 1200 of them, see http://www.vim.org. There are plugins for a wide variety of topics: CVS tools, project management, calendar, have you ever played with Vim Tetris?

Ftplugin means file type specific plugin. There are ftplugins which, for example, particularly support the syntax of HTML or Python or etc.

It is not difficult to write simple plugins yourself, e.g. to integrate additional menubars yourself.

Anyone who works with tables under vim will need Sorting functions to have.

The alphabetical sorting The following script can handle columns:

: call Cream_sortfile ()

It can even Sort date entries.

Sorting columns according to the size of numbers it can Not.

Since some web browsers such as B. w3m mastering the integration of editors, VIM can of course also use "wiki". There is also a small script for wiki syntax.

Vim's help system is very easy to expand (again user-specific, of course).


gvim only works after. However, this excludes, for example, the package vim-perl (Vi IMproved with Perl scripting support).

Navigation in long lines

Problem: Navigating in long lines: As long as I do not complete a line with Return, it will be automatically wrapped on the screen, e.g. it will span two lines on the screen. The up arrow, down arrow, Home and End keys do not refer to the lines on the screen, but to the actual lines (up to the end of line character). How can I comfortably navigate the lines on the screen? How do I get e.g. from screen line 2 directly to the character above it on the screen? With "normal" word processing, yes with the up arrow. And with vim?

To move in lines on the screen, you can use the normal mode

  • for downward and

  • use for upwards.

If necessary, you can also adjust the cursor keys accordingly. (See also: Vim FAQ, Section 9.4)


Use Cream as a simple configuration for Vim.


Pida is a graphical IDE that has a VIM (alternatively Cream) embedded as an editor - and offers many additional features, e.g. on the subject of version control, etc. Pida IDE website


cscope is an interactive program for navigating the source code. First, a database (cscope.out) is created in the source code directory with the command cscope-indexer. The information from the code analysis is saved here.

user @ host: / tmp / codetest $ tree. `- src | - main.c` - test.c user @ host: / tmp / codetest $ cscope-indexer -r user @ host: / tmp / codetest $ tree. | - cscope.files | - cscope.out `- src | - main.c` - test.c

Now we start vim in the directory in which the database is located (/ tmp / codetest).

Enter the following command to create a database connection:

The database connections can be displayed with show:

Now we want to search for the main function, this is done with the following command:

vim opens the file in which the main function is located and jumps to the correct line.

The help is displayed with: cscope help:

cscope commands: add: add a new database (usage: add file | dir [pre-path] [flags]) find: search for patterns (usage: find c | d | e | f | g | i | s | t name) c: Find functions calling this function d: Find functions called by this function e: Find this egrep pattern f: Find this file g: Find this definition i: Find files #including this file s: Find this C symbol t: Find assignments to help: display this message (usage: help) kill: interrupt connection (usage: kill #) reset: reinitialize connections (usage: reset) show: show connections (usage: show)

The command signal! means something like force - just type: help! a

Vim (last edited 2018-11-23 19:25:29 by JonesHamatoma)