Difference between revisions of "Vim"

From Lazarus wiki
Jump to navigationJump to search
(add some vim information)
 
m (Alextpp moved page vim to VIM: proper casing)
(No difference)

Revision as of 19:07, 1 February 2021

vim is an editor well-suited to program.

configuration

The vim editor experience can be enhanced for editing Pascal source code files.

margin

The ex-command

set colorcolumn=80

will change the background of the 80th column. Depending on the tabstop you may reach it earlier or later. This is just a visual guidance.

The textwidth variable will actually thwart insertion of lines longer than a certain width.

white characters

Using

set listchars=space:⍽

and then activating the “list mode” :set list, you can display all space characters with a custom symbol. This uses a different color than the actual character used.

navigation

The % key allows you to jump matching parenthesis and curly braces. However, extra precautions have to be taken for begin and end. You have enable the matchit plugin (cf. :help matchit-install):

packadd! matchit

If you like or have to view/edit source code written in SHOUTCASE, you need to add the following configuration setting:

let b:match_ignorecase = 1

folding

Confer :help folding.

The original editor of this article recommends manual folds using markers:

set foldmethod=marker

This will generate folds on markers. The default markers are {{{ and }}} (confer :help foldmarker). Thus, the following code

// procedure foo(integer, Boolean) {{{
procedure foo(const bar: integer; const able: Boolean);
begin
end;
// }}}

will look like

+--  5 lines: procedure foo(integer, Boolean) ----------------------------------

when folded.