vi

How do you open a file from within Vim?

亡梦爱人 提交于 2019-12-03 14:51:07
问题 I know how to open a file in vim from a terminal command line ( vim fileName ). What I can't figure out is how to open a file when I'm already within Vim. I tried :r fileName , but that appears to read (or append) the file into the unsaved buffer I have open. It creates a new file, because when I try to write it with :w , it asks for a filename. 回答1: :e <filename> or :Ex <directory> lets you browse for the file from the given directory. :Ex on its own will open the pwd. :enew will create an

Git - Do colours mean something in vi when I commit?

旧巷老猫 提交于 2019-12-03 14:41:32
问题 I'm using Git Bash on Windows and, when I run git commit , the vi editor opens to allow me writing a Commit note. I noticed that the first row of the text I write is yellow (although not all of it, only the first 30 or 40 characters), the second is white on a red background and from the 3rd onwards they are gray. Does this colour coding mean anything, or is it just some sort of weird glitch? I come from an SVN background, where Commit comment was pure text and I wasn't expecting this "rainbow

Is it possible to achieve the so-called “distraction free mode” in Vim?

北城以北 提交于 2019-12-03 14:25:28
Just curious, kinda like the "distraction free mode" of editors like sublime text , is it possible to centroid all the text to the middle of view field? It's always annoying to stare at the left-most end of the vim terminal in fullscreen mode with a widescreen monitor. Herbert Sitz You could take a look at VimRoom: http://projects.mikewest.org/vimroom/ Alternatively, you could set Vim up to have two or more vertical windows on your widescreen and have the same buffer automatically "snake" between them. Allows you to see two or three times as much of your buffer on the screen at once. See here

Switch between tabs in Sublime Text Vintage Mode

余生颓废 提交于 2019-12-03 14:18:48
I know we can achieve this in VIM using nerdtree and gT and gt commands. But is there any way to achieve similar kind of behaviour in Sublime Text Vintage Mode? I don't think Vintage mode has these bound to gt , gT or anything but Ctrl + Tab and Ctrl + Shift + Tab do exactly the same thing as gt and gT , whether you are in Vintage mode (INSERT or NORMAL) or not. You know, there is a very easy way to find the shortcuts used by an application: just look at the menu bar. That's what I did for you and it took less than 30 seconds. Or (for posterity), you can just paste this in your keymap file: {

linux上ES单机版安装

断了今生、忘了曾经 提交于 2019-12-03 14:09:59
设置 IP 地址 vi /etc/sysconfig/network-scripts/ifcfg-ens32 重启网卡 [root@localhost ~] systemctl restart network 关闭防火墙 [root@localhost ~]# systemctl stop firewalld [root@localhost ~]# systemctl disable firewalld 修改 hostname [root@localhost ~]# hostnamectl set-hostname centos_07 主机名和 IP 映射 [root@localhost ~]# vim /etc/hosts 注:如果是最小化安装,运行如下命令安装基本工具 yum install wget httpd-tools vim lrzsz 添加用户 [root@localhost ~]# adduser hadoop [root@localhost ~]# passwd hadoop 添加目录 [root@localhost ~]# mkdir /bd [root@localhost ~]# chown -R 用户名 文件夹路径 以下授权步骤可省略 [root@localhost ~]# whereis sudoers [root@localhost ~]# ls -l

vi使用方法详细介绍

一笑奈何 提交于 2019-12-03 13:24:39
知识点梳理来源于黑马教育 vi 编辑器是所有 Unix 及 Linux 系统下标准的编辑器,它的强大不逊色于任何最新的文本编辑器,这里只是简单地介绍一下它的用法和一小部分指令。由于对 Unix 及 Linux 系统的任何版本, vi 编辑器是完全相同的,因此您可以在其他任何介绍 vi 的地方进一步了解它。 Vi 也是 Linux 中最基本的文本编辑器,学会它后,您将在 Linux 的世界里畅行无阻。 1 、 vi 的基本概念   基本上 vi 可以分为三种状态,分别是命令模式( command mode )、插入模式( Insert mode )和底行模式( last line mode ),各模式的功能区分如下: 1) 命令行模式 command mode )   控制屏幕光标的移动,字符、字或行的删除,移动复制某区段及进入 Insert mode 下,或者到 last line mode 。 2) 插入模式( Insert mode )   只有在 Insert mode 下,才可以做文字输入,按「 ESC 」键可回到命令行模式。 3) 底行模式( last line mode )   将文件保存或退出 vi ,也可以设置编辑环境,如寻找字符串、列出行号 …… 等。 不过一般我们在使用时把 vi 简化成两个模式,就是将底行模式( last line mode )也算入命令行模式

Advanced searching in Vim

二次信任 提交于 2019-12-03 13:13:36
Is there a way to search for multiple strings simultaneously in Vim? I recall reading somewhere that it was possible but somehow forgot the technique. So for example, I have a text file and I want to search for "foo" and "bar" simultaneously (not necessarily as a single string, can be in different lines altogether). How do I achieve that? /^joe.*fred.*bill/ : find joe AND fred AND Bill (Joe at start of line) /fred\|joe : Search for FRED OR JOE Actually I found the answer soon after I posted this (yes I did google earlier but was unable to locate it. Probably was just searching wrong) The right

remap NERDTree Double Click to 'T'

蓝咒 提交于 2019-12-03 12:10:25
问题 Using VIM NERDTree Plugin. Is there any way to remap the Double Click on a File action to open the file silently in a new tab ( T )? 回答1: 1 Introduction This works for NERD tree version 4.2.0. 2 Open directories and files in a new tab If you would like to open directories and files in a new tab you can simply add the following line to your ~/.vimrc . let g:NERDTreeMapOpenInTabSilent = '<2-LeftMouse>' 3 Only open files in a new tab If you only want to open files in a new tab you have to do

Force Vi/Vim to use leading tabs only on retab!

喜你入骨 提交于 2019-12-03 11:50:41
问题 Is there a way to force vim to use tabs to do the initial indent, but when running the retab! command NOT replace inner word spacing with tabs? 回答1: In my experience the best way to do this is with a custom function: " Retab spaced file, but only indentation command! RetabIndents call RetabIndents() " Retab spaced file, but only indentation func! RetabIndents() let saved_view = winsaveview() execute '%s@^\( \{'.&ts.'}\)\+@\=repeat("\t", len(submatch(0))/'.&ts.')@' call winrestview(saved_view)