Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Practical work 2.doc
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
113.15 Кб
Скачать

2.4 Setting the initialization files vim

Every time you call my editor vim command reads from a file named. Exrc, that is in your own directory. This file is usually set predefined user options so there is no need to install them manually every time you call a vim.

File. Vimrc, and any other script files for vim, can contain everything that can be entered from the command line vim. Command to a file is usually written without the leading colon character.

Comments in. Vimrc start with double quotes ("). You can configure vim to your liking by editing the file $ HOME / .vimrc.

Example file .vimrc

"Vim

"A Sample vimrc.

"

"To use it, copy it

"For Unix and OS / 2: ~ /. vimrc

"For the Amiga: s:. vimrc

"For MS-DOS and Win32: $ VIM \ _vimrc

set nocompatible "Use the default Vim (much better!)

set bs = 2 "allow backspacing over everything in insert mode

set ai "always set autoindenting on

set backup "create back up file

set viminfo = '20, \ "50" read / write a. viminfo file, don't store more

"than 50 lines of registers

  "In text files, always limit the length to 78 characters

  autocmd BufRead *. txt set tw = 78

  "For Win32 GUI: remove the flag 't' of 'guioptions': no ​​tearoff menu entries

  "Let & guioptions = substitute (& guioptions," t ", " ", " g ")

  "Do not use mode Ex, use Q for formatting  

map Q gq

  "Enable syntax highlighting, if the terminal is color

  "Also, turn on the backlight of the last search pattern.

  if & t_Co> 2 | | has ("gui_running")

    syntax on

    set hlsearch

  endif

  augroup cprog

    "Remove all automatic commands cprog

    au!

    "When you start to edit the file:

    "For *. C and *. H files set formatting of comments and

    "Set C-indenting on.

    "For other files, set it off.

    "Do not change the order, it is important that the line starting with *.

    autocmd BufRead * set formatoptions = tcql nocindent comments & autocmd BufRead *. c, *. h set formatoptions = croql cindent comments = sr :/ *, mb: *, el: * /, :/ /

  augroup END

  augroup gzip

    "Remove all automatic commands gzip

    au!

    "Allow editing of gzipped files

    "Read: set binary mode before reading the file

    "Unclench text in buffer after reading

    "Write: compress file after writing

    "Append: decompress the file, add the file to compress

    autocmd BufReadPre, FileReadPre *. gz set bin

    autocmd BufReadPost, FileReadPost *. gz let ch_save = & ch | set ch = 2

    autocmd BufReadPost, FileReadPost *. gz '[,']! gunzip

    autocmd BufReadPost, FileReadPost *. gz set nobin

    autocmd BufReadPost, FileReadPost *. gz let & ch = ch_save | unlet ch_save

    autocmd BufReadPost, FileReadPost *. gz execute ": doautocmd BufReadPost". expand ("%: r")

    autocmd BufWritePost, FileWritePost *. gz! mv <afile> <afile>: r

    autocmd BufWritePost, FileWritePost *. gz! gzip <afile>: r

    autocmd FileAppendPre *. gz! gunzip <afile>

    autocmd FileAppendPre *. gz! mv <afile>: r <afile>

    autocmd FileAppendPost *. gz! mv <afile> <afile>: r

    autocmd FileAppendPost *. gz! gzip <afile>: r

    augroup END

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]