本文介绍了在VIM OSX终端上添加永久号码行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在osx终端中遇到了vim的命令,该命令使您可以查看预定的.c文档(即:set number)中的每一行.我想在每次创建或打开文档时将此参数设置为默认值.

进行搜索后,我发现:您可以将:set number附加到vi ~/.vimrc

首先,这是什么文件?您如何访问它,以及如何向其附加这样的命令?

我尝试在vim文档中搜索.vimrc,但这没有多大意义,因为它谈到有4个初始化位置,等等..."

解决方案

注意:如果在Windows上,.vimrc称为_vimrc

您的.vimrc文件应在主目录(~)中创建.这是一个脚本,每次启动vim时都会运行,并且应包含对编辑器的自定义设置,例如set number命令.它允许您自定义和编程" vim.如果希望在每次启动vim时都调用:set number,则应将其放置在vimrc中,以便在每次vim启动时都可以运行.

在主目录中使用vim(或任何其他文本编辑器)创建一个.vimrc(文本)文件

$ cd ~
$ vim .vimrc

然后添加此行:

set number

请注意,没有:.这是因为这不再是命令行命令,而是作为vimscript代码执行.

.vimrc文件可用于重新映射其他命令的键,创建您自己的命令,打开设置编号(还有更多)来启用插件等选项.因此,每个人都有一个不同的.vimrc文件,因为他们使用vim而制作.我经常在vim中进行编码,并决定使用一个命令让您更有效地执行某件事会很好,因此,我打开.vimrc并添加可以帮助我更快地进行编码的内容.

随着您越来越多地使用vim,您将发现可以放入.vimrc的良好优化,并且文件将开始增长.您可以在google示例vimrcs上查看非常酷的设置,这些设置将帮助您更快或更佳地进行编码.

在vim中,使用:h vimrc查看有关它的更多信息.

有关如何制作优质vimrc的网站,请参见此处./p>

I have come across a command for vim in osx terminal that allows you to view each line in a predetermined .c document, which is :set number. I want to set this parameter to be on default each time a document is created or opened.

After doing a search I came across this: you can append :set number to vi ~/.vimrc

First, what is this file? How do you access it, and how do I append such a command to it?

I've tried searching the vim docs for .vimrc, but it doesn't make much sense as it talks about there being "4 places for initialisations, etc..."

解决方案

Note: If you are on windows the .vimrc is called _vimrc

Your .vimrc file should be created inside your home directory (~). This is a script that is run everytime you start vim and should contain customizations to the editor such as the set number command. It allows you to customize and "program" vim. If you want :set number to be called every time you start vim, you should place it inside your vimrc to be run everytime vim starts.

Create a .vimrc (text) file with vim (or with any other text editor) in your home directory

$ cd ~
$ vim .vimrc

Then add this line:

set number

Notice there is no :. That is because this is not a command line command anymore and instead is executed as vimscript code.

The .vimrc file is useful for remapping keys to other commands, creating your own commands, turning on options like set number (there are many more) enabling plugins etc... For this reason, everyone has a different .vimrc file, which has been crafted as they use vim. I am often coding in vim, and decide it would be nice to have a command that you let me do something more efficiently, so I open up my .vimrc and add in something that would help me code faster.

As you use vim more and more, you will discover good optimizations to put in your .vimrc and the file will start to grow. You can google example vimrcs to see very cool settings that will help you code faster or better.

While in vim, use :h vimrc to see more information about it.

See here for a website about how to make a good vimrc.

这篇关于在VIM OSX终端上添加永久号码行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 15:45