vi

How do I fix the indentation of an entire file in Vi?

有些话、适合烂在心里 提交于 2019-11-27 09:55:16
In Vim, what is the command to correct the indentation of all the lines? Often times I'll copy and paste code into a remote terminal and have the whole thing messed up. I want to fix this in one fell swoop. Logan Capaldo = , the indent command can take motions. So, gg to get the start of the file, = to indent, G to the end of the file, gg=G . Before pasting into the terminal, try :set paste (and then :set nopaste after you're done). This will turn off the auto-indent, line-wrap, etc. features that are messing up your paste. edit: Also, I should point out that a much better result than =

What are the dark corners of Vim your mom never told you about? [closed]

守給你的承諾、 提交于 2019-11-27 09:54:40
There are a plethora of questions where people talk about common tricks, notably " Vim+ctags tips and tricks ". However, I don't refer to commonly used shortcuts that someone new to Vim would find cool. I am talking about a seasoned Unix user (be they a developer, administrator, both, etc.), who thinks they know something 99% of us never heard or dreamed about. Something that not only makes their work easier, but also is COOL and hackish . After all, Vim resides in the most dark-corner-rich OS in the world, thus it should have intricacies that only a few privileged know about and want to share

Using normal-mode motions in command-line mode in Vim

倖福魔咒の 提交于 2019-11-27 09:44:23
问题 Is modal editing possible in command-line mode? Some examples: After writing !ls ~/foo/bar I want to db to delete bar I executed the above command and now I want to change ls to mv and jump back to $ 回答1: By default you can press Control + f (or otherwise see set cedit ) when on the Vim command-line, which opens the command-line window where you can edit the command using normal-mode Vim editing keys. Enter will run the command or Control + c will return you to the standard command-line. So

how to copy codes in vi to clipboard

南笙酒味 提交于 2019-11-27 08:22:20
I know how to copy in VI. but I failed to copy it into other application. That means I failed copy those into clipboard. How can I do this? P.S. In order to lean more. I also want to ask how to copy content from clipboard to vi. Edited: I am using MacOs. running Vim. It seems *yy doesn't work here. Any other ways? You need to use the clipboard register, which is * , so to copy a line of text into clipboard: "*yy To paste a line of text from the clipboard: "*p "+y or "*y works only if your vim supports the xterm_clipboard. Xterm is a terminal emulator for X11. Try vim --version to see if it is

程序员专用文本编辑器MacVim

给你一囗甜甜゛ 提交于 2019-11-27 07:41:21
MacVim for Mac版 是一个将Vim程序员编辑器带入Mac的项目。另一方面,Vim基于强大的Vi应用程序,这是一个为Unix操作系统开发的文本编辑器。除了其他功能之外,MacVim应用程序还支持使用热键,包括全屏模式,允许您使用透明背景等等。请记住,即使MacVim可以处理文本,它也不是一个WYSIWYG处理器。 MacVim for Mac软件介绍 Vim是一个高级文本编辑器,旨在提供事实上的Unix编辑器'Vi'的强大功能,具有更完整的功能集。无论您是使用vi还是使用其他编辑器,它都很有用。Vim是一个很好的旧UNIX编辑器Vi的改进版本。添加了许多新功能:多级撤消,语法突出显示,命令行历史记录,联机帮助,拼写检查,文件名完成,块操作,脚本语言等。还提供了图形用户界面(GUI)。仍然保持Vi的兼容性,那些拥有Vi“手指”的人会有宾至如归的感觉。请参阅runtime/doc/vi_diff.txt与Vi的差异。此编辑器对于编辑程序和其他纯文本文件非常有用。所有命令都使用普通的键盘字符,因此可以用十个手指键入的人可以非常快速地工作。另外,功能键可以由用户映射到命令,并且可以使用鼠标。Vim运行在MS-Windows(NT,2000,XP,Vista,7,8,10),Macintosh,VMS和几乎所有类型的UNIX下。移植到其他系统应该不是很困难。较旧版本的Vim可在MS

How to include forward slash in vi search & replace

三世轮回 提交于 2019-11-27 07:10:24
I have a file that contains the string usrbin . I want to search for usrbin and replace it with /usr/bin/ . I tried :%s/usrbin/usr/bin/g , but it's showing error E488: Trailing characters . How do I include a forward slash in a search and replace? pb2q Here are two ways: escape the / which is the default substitute separator: :s/usrbin/\/usr\/bin use another substitute separator, e.g., using the hash # character: :s#usrbin#/usr/bin . Note that there are characters that you can't use as a separator: " , \ , | 来源: https://stackoverflow.com/questions/11823616/how-to-include-forward-slash-in-vi

vim toggling buffer overwrite behavior when deleting

自作多情 提交于 2019-11-27 07:07:18
问题 Vim is great, but like many people I get really annoyed when I want to copy, delete, then paste -- the yank buffer gets overwritten by the delete action. Now I know there are 101 work-arounds and mappings, some of which are enumerated in posts like this one: Any way to delete in vim without overwriting your last yank? But all of these solutions have drawbacks -- even I were a buffer-guru (which I'm not). For instance, excess keystrokes -- whereas I normally xxxx to quickly delete 4 characters

第二周 测试

谁说胖子不能爱 提交于 2019-11-27 06:32:35
测试 实验 vi 每个 .c一个文件,每个 .h一个文件,文件名中最好有自己的学号; 用Vi输入图中代码,并用gcc编译通过; 在Vi中使用K查找printf的帮助文档,提交vi编辑过程截图。 gcc 用gcc 进行预处理,编译,汇编,链接vi输入的代码; 生成的可执行文件中要有自己的学号; 提交预处理,编译,汇编,链接,运行过程截图。 gdb 用gcc -g编译vi输入的代码; 在main函数中设置一个行断点; 在main函数增加一个空循环,循环次数为自己学号后4位,设置一个约为学号一半的条件断点。 静态库 除了main.c外,其他4个模块(add.c sub.c mul.c div.c)的源代码不想给别人,如何制作一个mymath.a静态库?main.c如何使用mymath.a? 共享库 除了main.c外,其他4个模块(add.c sub.c mul.c div.c)的源代码不想给别人,如何制作一个mymath.so共享库?main.c如何使用mymath.so? Makefile 写出编译上面vi编辑代码的makefile,编译出来的目标文件为testmymath, 只用显式规则就可以。 代码 head.h #ifndef HEAD_H #define HEAD_H int add(int ,int); int sub(int ,int); int mul(int ,int

Python实现电子词典(图形界面)

那年仲夏 提交于 2019-11-27 06:30:00
Python实现电子词典(图形界面) 终端电子词典 :https://www.cnblogs.com/noonjuan/p/11341375.html 文件一览: . ├── client.py ├── data.py ├── dic.csv ├── func.py ├── pics │ ├── pic_login.jpg │ ├── pic_main.jpg │ └── pic_signup.jpg ├── readme.txt ├── server.py └── settings.py pics文件图片一览: 运行截图: 代码一览: 图形化界面电子词典 编程语言:Python 环境支持:Ubuntu 16.04、MySQL 使用模块:pymysql、socket、tkinter 编程文件:server.py、client.py、settings.py、data.py、func.py data.py: 1、创建dictionary数据库 2、创建userinfo、dictionary、history等表 3、将文本数据导入数据库中 func.py: send:套接字发送函数 recv:套接字接收函数 server.py: main函数:循环接收客户端连接请求 handler函数:处理客户端连接成功后的其他请求 client.py: main函数:主循环事件 Handler类

Linux vi arrow keys broken in insert mode

非 Y 不嫁゛ 提交于 2019-11-27 06:09:38
My arrow keys don't work in vi in insert mode at home, they just each insert a newline and a capital letter, like 'A'. Is there a way to fix that? Brian Agnew I presume you're using vim as this is tagged as Linux. Try: :set nocompatible (You may want to configure your .vimrc with this by adding this command to it. Create a new .vimrc file if not already present in your home directory, run echo $HOME to check home directory path.) Ubuntu ships default with vim-tiny , which doesn't have all the bells and whistles that vim has. Do a quick sudo apt-get install vim to get all the juicy features