vi

Best way to insert timestamp in Vim?

南笙酒味 提交于 2019-11-27 06:03:40
EditPad Lite has a nice feature ( CTRL - E , CTRL - I ) which inserts a time stamp e.g. "2008-09-11 10:34:53" into your code. What is the best way to get this functionality in Vim? (I am using Vim 6.1 on a Linux server via SSH. In the current situation a number of us share a login so I don't want to create abbreviations in the home directory if there is another built-in way to get a timestamp.) http://kenno.wordpress.com/2006/08/03/vim-tip-insert-time-stamp/ Tried it out, it works on my mac: :r! date produces: Thu Sep 11 10:47:30 CEST 2008 This: :r! date "+\%Y-\%m-\%d \%H:\%M:\%S" produces:

How do I tidy up an HTML file's indentation in VI?

强颜欢笑 提交于 2019-11-27 05:51:19
How do I fix the indentation of his huge html files which was all messed up? I tried the usual "gg=G" command , which is what I use to fix the indentation of code files. However, it didn't seem to work right on HTML files. It simply removed all the formatting. I also tried setting :filetype = xml , to see if tricking it into thinking this was an XML file would help but it still didn't do it. marcog With filetype indent on inside my .vimrc , Vim indents HTML files quite nicely. Simple example with a shiftwidth of 2: <html> <body> <p> text </p> </body> </html> There's several things that all

Move entire line up and down in Vim

廉价感情. 提交于 2019-11-27 05:45:21
In Notepad++, I can use Ctrl + Shift + Up / Down to move the current line up and down. Is there a similar command to this in Vim? I have looked through endless guides, but have found nothing. If there isn't, how could I bind the action to that key combination? Edit: Mykola's answer works for all lines, apart from those at the beginning and end of the buffer. Moving the first line up or the bottom line down deletes the line, and when moving the bottom line up it jumps two spaces initially, like a pawn! Can anyone offer any refinements? Put the following to your .vimrc to do the job noremap <c-s

Setting the Vim background colors

﹥>﹥吖頭↗ 提交于 2019-11-27 05:02:30
问题 When I try to change the background colors in .vimrc or directly in Vim using the command: set background=dark ... it doesn't affect my background at all. Neither does the light option. However, it looks okay when I run gvim. Is there a way to change the background in Mim without changing my Konsole settings? EDIT Okay, there is a difference between guifg/guibg and ctermfg/ctermbg. While the GUI accepts lots of different color combinations, cterm allows only few standard ones. 回答1: As vim's

What is the best way to force yourself to master vi? [closed]

杀马特。学长 韩版系。学妹 提交于 2019-11-27 04:54:54
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . A good while ago, I read an article by the creator of viemu, clearing up a lot of the misconceptions about vi, as well as explaining

【正确使用vim编辑器的姿势】

笑着哭i 提交于 2019-11-27 02:49:26
原文: http://106.13.73.98/__/87/ vi:可视化接口 (Visual Interface) vim:是vi的增强版 (vi iMprove) vi 编辑器是所有Unix及Linux系统下标准的编辑器,他就相当于windows系统中的记事本一样,它的强大不逊色于任何最新的文本编辑器。它是我们使用Linux系统不能缺少的工具。Unix及linux系统的任何版本下的vi编辑器是完全相同的,学会它后,您将在Linux的世界里畅行无阻。 vim 可以说的vi的升级版本,它可以用多种颜色的方式来显示一些特殊的信息。 vim 具有程序编辑能力,可以以字体颜色辨别语法的正确性,方便程序设计。 vim 会依据文件扩展名或者是文件内的开头消息,来判断该文件的内容而自动的执行该程序的语法判断式,再以颜色来区分显示代码与注册信息。 vim 加入了很多额外的功能,例如支持正则表达式的搜索、多文件编辑、快复制等等。这帮助我们在进行一些配置文件的修改工作时提高了不少的效率。 vim 有三种工作模式,如下图: vim编辑器的配置文件:全局 /etc/vimrc 用户 ~/.vimrc 修改配置文件可使某项配置默认生效,比如在配置文件内加入一行: set nu ,那么打开文件后将默认显示行号。 打开文件 vim + file 打开文件并定位到最后一行 . vim +n file

Copy all the lines to clipboard

*爱你&永不变心* 提交于 2019-11-27 02:19:56
Is there any way to copy all lines from open file to clipboard in VI editor. I tried y G but it's not using clipboard to store those lines. So is it possible? CMS You should yank the text to the * or + registers : g g " * y G Explanation: gg to get the cursor to the first character of the file "*y to start a yank command to the register * from the first line, until... G to go the end of the file Rook Use: : % y + to yank all lines. Explanation: % to refer the next command to work on all the lines y to yank those lines + to copy to the system clipboard NB : In Windows, + and * are equivalent

Is it possible to use VI or VIM keymap in NetBeans?

做~自己de王妃 提交于 2019-11-27 01:35:32
问题 Vim is my favorite tool for programming in OSX, but my team mate all use NetBeans. Some of them use Eclipse Keymap. Any suggestion plug-in to enable VI command in NetBeans 6.5? Related: Does any IDE have a vi keybindings option? 回答1: Check jVi, a Vi emulator for NetBeans. I've also found ViEx, the project seems to be pretty active... 回答2: jVi can be installed using the NetBeans plugin manager; from NB do Menu>Tools>Plugins Select the tab "Available Plugins", in search enter "jvi". First

Centos7——VI和VIM编辑器

时光怂恿深爱的人放手 提交于 2019-11-27 00:48:00
目录 VI 和 VIM 的基本介绍 VI 和 VIM 的三种常见模式 快速入门案例 VI 和 VIM 三种模式的相互转化图( 重点 ) 快捷键的使用案例 VIM 和 VI 的快捷键键盘一览图 目录 VI 和 VIM 的基本介绍 VIM 程序编辑的能力,可以看作是 VI 的增强版。 VI 和 VIM 的三种常见模式 正常模式 在正常模式下,可以使用快捷键 以 vim 打开一个档案就直接进入一般模式(默认模式)。在该模式下,可以使用【上下左右】按键来移动光标,可以使用【删除字符】或【删除整行】来处理档案内容,也可以使用【复制、粘贴】来处理文件数据。 插入模式/编辑模式 在该模式下,可以输入内容。 按下i,I,a,A 等任何一个字母之后才会进入编辑模式,一般按 i 即可 命令行模式 在该模式下,用相关指令,完成读取、存盘、替换、离开 vim、显示行号等! 快速入门案例 使用 vim 开发一个 Hello.java 程序,保存即可。 VI 和 VIM 三种模式的相互转化图( 重点 ) 快捷键的使用案例 ①. 拷贝当前行 【yy】,拷贝当前行向下的 5 行 【5yy】,并粘贴 【p】。 删除当前行 【dd】,删除当前行向下的 5 行 【5dd】。 ②. 在文件中查找某个单词 【命令模式下 /关键字,回车 查找,输入 n 就是查找下一个】,查hello。 ③. 设置文件的行号,取消文件的行号

vim backspace leaves ^?

♀尐吖头ヾ 提交于 2019-11-27 00:00:33
问题 In Vim, when I hit the backspace key in the insert mode, it leaves ^? character and does not delete the character it is suppose to delete. I have the following in my .vimrc syntax on set number set expandtab set incsearch set nocompatible set backspace=indent,eol,start fixdel This happens in the command mode too. When I wrongly type W instead of w to save, I press backspace key and it gives me the following: :W^? Any idea on whats wrong and how to fix it?! UPDATE: before posting this question