vi

Syntax highlighting randomly disappears during file saving

╄→尐↘猪︶ㄣ 提交于 2019-12-10 03:45:19
问题 I'm using vim to edit some python files and recently it occurs sporadically that the syntax highlighting disappears after I save the buffer inside vim. I tried to reset syntax on and set filetype=python but to no avail. I have no clue of what causes this problem at all, so right now I have minimal diagnostic info. But has anyone encountered this before, or where could things break down? 回答1: This is not a solution, but it's hard to write/read in the comments. I meant that I was messing around

vim多标签、多窗口操作

ⅰ亾dé卋堺 提交于 2019-12-10 02:03:38
多标签 欢迎访问 www.zhizhi123.com ,汇聚WEB开发知识 进入vim前 vim -p <文件名> 以多标签形式打开文件。如vim -p * 就是编辑当前目录的所有文件 vim编辑中 :tabnew 增加一个标签 :tabc 关闭当前的tab :tabo 关闭所有其他的tab :tabs 查看所有打开的tab :tabp 或gT 前一个 :tabn 或gt 后一个 新建标签页 :tabe <文件名> 在新标签页中打开指定的文件。 :tabnew <文件名> 在新标签页中编辑新的文件。 :tab split 在新标签页中,打开当前缓冲区中的文件。 :tabf 允许你在当前目录搜索文件,并在新标签页中打开。比如:tabf img.*。此命令只能打开一个文件. Vim默认最多只能打开10个标签页。你可以用set tabpagemax=15改变这个限制。 列示标签页 :tabs 显示已打开标签页的列表,并用“>”标识出当前页面,用“+”标识出已更改的页面。 切换标签 :tabfirst或:tabr 移动到第一个标签页。 :tablast 移动到最后一个标签页。 移动标签页 :tabm [次序] 移动当前文件的标签页次序。比如:tabm 1将把当前标签页移动到第2的位置。如:tabm不指定参数将被移动到最后。 配置标签页 :set showtabline=0 不显示标签栏

如何显示VI中的标签的文件名

跟風遠走 提交于 2019-12-10 01:48:04
在xshell的VI编辑器中,如果显示标签的文件名,那么在编辑过程中便会一目了然非常方便,那么要如何显示标签的文件名呢?本集 xshell教程 就为大家讲解具体操作方法。   VI编辑器中有一个功能,允许用户自定义终端名称。你可以使用xshell中“显示终端名称”功能来显示在VI编辑器中的标签名称。具体操作如下:      图1:终端类型选择Xterm    1、将xshell终端类型设置为xterm   1)打开xshell,点击会话属性对话框   2)在弹出的对话框中选择“终端”   3)在终端类型的下拉表中选择xterm   此外关于xshell的VI编辑器颜色设置可以参考: 如何使用命令使VI和VIM显示颜色    2、打开 $HOME/.vimrc以及输入下面的命令:   auto BufEnter * let &titlestring = hostname() . " - " . expand("%:p")   set title    3、在xshell中右击选项卡,选择显示终端标题菜单   以上就是xshell中如何显示标签文件名的具体操作方法,更多教程,敬请关注 Xshell中文网 。 来源: oschina 链接: https://my.oschina.net/u/2611533/blog/667018

How to pipe visually selected text to a UNIX command and append output to current buffer in Vim

独自空忆成欢 提交于 2019-12-09 16:43:04
问题 Using Vim, I'm trying to pipe text selected in visual mode to a UNIX command and have the output appended to the end of the current file. For example, say we have a SQL command such as: SELECT * FROM mytable; I want to do something like the following: <ESC> V " select text :'<,'>!mysql -uuser -ppass mydb But instead of having the output overwrite the currently selected text, I would like to have the output appended to the end of the file. You probably see where this is going. I'm working on

Some questions on .vimrc and vim configuration

可紊 提交于 2019-12-09 15:45:54
问题 Generally on a unix system, there is a global vimrc file in the directory /etc or /etc/vim . You can also have a .vimrc file in your home directory that can customize your vi session. Is it possible to have a .vimrc elsewhere in your directory tree so you can use different vi properties in different directories? This would be convenient because the editor properties that help you edit Python most quickly are different from those for editing, say, HTML. This sort of thing does not seem to work

Possible to change length of tab depending on file extension? [duplicate]

时光怂恿深爱的人放手 提交于 2019-12-09 15:42:07
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Changing Vim indentation behavior by file type Hello. So, I switch between '2' and '4' spaces for tabs very often. Usually I use 2 spaces for a tab for HTML files and 4 spaces for a tab for programming. Is there anyway to configure VIM, so it will automatically adjust depending on the file extension? Also, how come VIM indents 8 spaces sometimes, like after I enter an open brace? I have it set to 4 spaces.

Linux 使用vi命令的教程

佐手、 提交于 2019-12-09 14:14:18
一、首先用vi命令打卡要编辑的文件: 注意:vi命令的使用如下: 打开或新建文件,并将光标至于第一行首:[root@centos6 /]# vi /etc/my.cnf 打开文件,并将光标移至最后一行行首:[root@centos6 /]# vi + /etc/my.cnf 打开文件,并将光标置于第n行首:[root@centos6 /]# vi +n /etc/my.cnf 打开文件,并将光标置于第一个与pattern匹配的串处:vi +/pattern filename 二、按键盘上“a”键,vi界面出现 INSERT后,开始进行编辑操作 三、编辑完毕后,按ESC键,跳到命令模式,然后进行保存退出或不保存退出操作: 保存,不退出vi----------------------- :w 强制保存,不退出vi----------------------- :w! 将修改另外保存到file中,但不退出vi(不常用)----------------------- :w file 保存,并退出vi----------------------- :wq 或 :x 强制保存,并退出vi----------------------- :wq! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~华丽的分割线~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 下面是不保存的相关命令

How to compute the number of times word appeared in a file or in some range

自作多情 提交于 2019-12-09 08:14:11
问题 Sometimes I want to see how many times a certain function is called in a file or a code block. How do you do that? I am using Vim 7.2. I presume you have to use !wc or some such. 回答1: For counting the number of times some pattern occurs, use: :%s/pattern//gn The 'n' flag count the number of occurrences without doing any change to the document. For counting the total number of words, you have several options. If you want to run as an external command: :!wc -w % If you want to run it inside VIM

VIM - Sourcing tags from multiple locations in project

回眸只為那壹抹淺笑 提交于 2019-12-09 06:25:35
问题 Good day, I typically work on relatively small (less than 20,000 lines of code) projects that are all self contained within a single directory, have their own Makefile, and are fairly easy to work with. VIM is my preferred editor, and when I open a project, I typically build the ctags list via a mapping to the F10 key: map <F10> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR> This allows me to jump to the definition of a variable/struct/etc via moving the cursor over the text, and

Getting root permissions on a file inside of vi? [closed]

北城以北 提交于 2019-12-09 04:00:37
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 months ago . Often while editing config files, I'll open one with vi and then when I go to save it realize that I didn't type sudo vi filename Is there any way to give vi sudo privileges to save the file? I seem to recall seeing something about this while looking up some stuff about vi a while ago, but now I can't find it.