The first line is an expression mapping for normal, visual, and operator pending modes. The right-hand side of the mapping is an expression that is evaluated each time Home is pressed. The expression gives a string, and the result is as if the characters in the string had been pressed. The expression compares col('.') (the cursor column position, where 1 is the first column) and match(getline('.'),'\S')+1 (the index of the first non-whitespace character in the current line; 1 is added because the index starts at 0). If both sides of "==" are equal, the result is '0' (move to start of line); otherwise it is '^' (move to first nonblank character).

In insert mode, the second line applies and if Home is pressed the result is Ctrl-O followed by Home. In insert mode, pressing Ctrl-O executes what follows as a normal-mode command, so the Home which follows invokes the normal mode mapping.

The simple mappings have two deficiencies:

If there are no non-whitespace characters, match() returns −1 which becomes 0 after adding 1, and that value never equals the result from col('.'). Therefore the mapping always performs ^.

The mapping does not account for the case where the 'wrap' option is on and long lines are wrapped. In that case, pressing Home will jump to the first nonblank character or the start of the line, whereas moving to the start of the screen line may be wanted.

If lines are not wrapped, the following operates in the same manner as the above simple mappings, except that it works correctly on a line which consists only of whitespace characters.

If options 'wrap' and 'linebreak' are on, long lines will wrap and wrapped lines will start with a non-whitespace character. In that case, if the cursor is on a character in the middle of a wrapped line, pressing Home will move to the start of that screen line (not the start of the line of text in the buffer). Pressing Home again will move to the first nonblank character of the line in the buffer (on a different screen line). Pressing Home a third time will move to the start of the line.