mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-08 21:34:25 +00:00
1.9 KiB
1.9 KiB
Vim
Table of contents
TL;DR
# Go to a particular line.
42G
42gg
:42<CR>
# Delete all file's lines.
:1,$d
# Substitute 4-spaces indentations with tabs.
:%s/ /\t/g
# Enable auto indentation per file type.
:filetype plugin indent on
# Render existing tab as 4 spaces in width.
:set tabstop=4
# Insert 4 spaces of width when indenting with '>'.
:set shiftwidth=4
# Insert 4 spaces when indenting with 'tab'.
:set expandtab
# Align the file to the current indentation settings.
:retab
# Get help on something.
:help modeline
Modelines
Set different options for a particular file.
The
modelineoption must be enabled in order to take advantage of this.
This option is set by default for Vim running in nocompatible mode, but some notable distributions of Vim disable it in the system'svimrcfor security. In addition, the option is off by default when editing asroot.
See :help modeline for more information.
The modeline line needs to:
- be placed near the top of the file; how near, will depend on the modeline settings
- start with a comment opening for the file type.
The space between the comment opening and 'vim' is necessary for the modeline to be recognized.
Examples:
# vim: set expandtab:
# -*- mode: ruby -*-
# vi: set ft=ruby :
/* ex: set ts=8 sw=4 tw=0 noet : */