- Mastering Vim
- Ruslan Osipov
- 484字
- 2021-06-10 18:51:24
Configuring Vim with your .vimrc
Vim reads configuration from a .vimrc file. Vim works out of the box, but there are certain options which make working with code a lot easier.
In Linux and MacOS, .vimrc is located in your user directory (the full path would be /home/<username>/.vimrc). You can also find out your user directory by opening a Command Prompt and running the following command:
$ echo $HOME
Windows does not allow periods in file names, so the file is named _vimrc. It's usually located in C:\Users\<username>\_vimrc, but you can also locate it by opening the Windows Command Prompt and running the following command:
$ echo %USERPROFILE%
Find the proper location for your OS, and place the prepared configuration file there. You can download the .vimrc used for this chapter from GitHub at https://github.com/PacktPublishing/Mastering-Vim/tree/master/Chapter01. The following code shows the contents of a .vimrc file used in this chapter:
syntax on " Enable syntax highlighting.
filetype plugin indent on " Enable file type based indentation.
set autoindent " Respect indentation when starting a new line.
set expandtab " Expand tabs to spaces. Essential in Python.
set tabstop=4 " Number of spaces tab is counted for.
set shiftwidth=4 " Number of spaces to use for autoindent.
set backspace=2 " Fix backspace behavior on most terminals.
colorscheme murphy " Change a colorscheme.
Lines starting with a double quote " are comments and are ignored by Vim. These settings bring in some sensible defaults, like syntax highlighting and consistent indentation. They also fix one of the common sticking points in a bare-bones Vim installation—inconsistent backspace key behavior across different environments.
I've also changed the colorscheme to make screenshots look better in print, but you don't have to.
- Windows系統(tǒng)管理與服務(wù)配置
- 架構(gòu)不再難(全5冊(cè))
- PHP+MySQL網(wǎng)站開(kāi)發(fā)技術(shù)項(xiàng)目式教程(第2版)
- Mastering Python High Performance
- Oracle BAM 11gR1 Handbook
- Learning AndEngine
- JavaScript 程序設(shè)計(jì)案例教程
- Learning Hunk
- 組態(tài)軟件技術(shù)與應(yīng)用
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)教程(Windows 7+Office 2010)
- Kotlin Programming By Example
- Mastering Elixir
- Monitoring Docker
- Qt 5.12實(shí)戰(zhàn)
- R語(yǔ)言編程:基于tidyverse