vi

Vim yanking range of lines

心不动则不痛 提交于 2019-11-28 16:15:35
问题 I'm a C# developer who has just recently decided to expand my knowledge of the tools available to me. The first tool I've decided to learn is Vi/Vim. Everything has been going well so far, but there are a couple of questions I can't seem to find the answer to: Lets say I wanted to yank a range of lines. I know there are many ways of doing so, but I would like to do it by line number. I figured it would be similar to how the substitute commands work, something like 81,91y . Is there a way to

How to replace text between quotes in vi

一笑奈何 提交于 2019-11-28 15:56:12
Say I have this line of code: $query = "SELECT * FROM table"; Is there a command in vi/vim which can instantly delete everything between quotes and position the cursor between them so I can start typing? Eugene Yarmash Use ci" , which means: change what inside the double quotes. You can also manipulate other text objects in a similar way, e.g.: ci' - change inside the single quotes ciw - change inside a word ci( - change inside parentheses dit - delete inside an HTML tag, etc. More about different vim text objects here . You can select between quotes and then delete ( d ), change ( c ) etc.

Change File Encoding to utf-8 via vim in a script

不羁岁月 提交于 2019-11-28 15:39:06
i just got knocked down after our server has been updated from Debian 4 to 5. We switched to UTF-8 environment and now we have problems getting the text printed correctly on the browser, because all files are in non-utf8 encodings like iso-8859-1, ascii, etc. I tried many different scripts. The first one i tried is "iconv". That one doesnt work, it changes the content, but the files enconding is still non-utf8. Same problem with enca, encamv, convmv and some other tools i installed via apt-get. Then i found a python code, which uses chardet Universal Detector module, to detect encoding of a

How to copy and paste between different tmux panes running vim instances

痞子三分冷 提交于 2019-11-28 15:29:57
问题 Example: copy in one tmux pane (via vim), then switch to another pane (running another vim instance) and paste using the vim paste command. I know this can be done via tmux (using prefix+]) but it would be really handy if I can copy and paste using vim bindings since i'm just switching between different panes running vim. Any ideas? 回答1: Sorry, I'm trying to convince you to use vim built-in features. To make the copy/paste easy, you can open files in another Tabpages: :tabe /path/to/another

Vim的几个高级玩法

强颜欢笑 提交于 2019-11-28 15:26:18
文章目录 vim的几种模式 扩展命令模式命令: 命令模式高频命令: 命令模式进阶命令: vim高级玩法 小结:  在Linux中编辑文件的场景非常之多,掌握一些关键命令和技巧。能够大大提高效率,使用体验也顺畅很多。  1976年由Bill Joy完成编写vi,并由BSD发布。从2006年开始,作为“单一UNIX规范”的一部分,vi或vi的一种变形版本一定会在类UNIX系统中找到。 vim是vi的一个变形版本,功能更加强大,体验更好。 vim的几种模式  新手使用vim最麻烦的就是模式,因为经常忘记自己处在何种模式,无意键入某个字符,就切换到其他模式。 vim的模式有以下几种:其中红色部分和命令模式最常使用。 命令模式 :启动后的默认模式。其他模式,通过【Esc】和【Ctrl+C】可以退回到该模式 插入模式 :此模式下可以编辑。i: 在当前光标开始插入。 o: 进入插入模式,并在光标下一行添加一个新的空行 扩展命令模式 : 使用“:” 切换到此模式。 可视模式。在该模式下,可以使用方向键进行内容选择,然后进行复制、粘贴或其他操作。在命令模式下,使用“v”进入可视模式。 v: 进入可视模式,方向键可以选择文本。 x可以剪切,y复制,d删除 当输入了命令以后,VIM 将回到普通模式,这时可以按 p 或 P 进行粘贴。普通模式下有关复制和粘贴的命令:p或P 在当前位置粘贴剪贴板的内容,p

How can I permanently display the path of the current file in Vim?

守給你的承諾、 提交于 2019-11-28 15:22:23
I know CTRL g displays the current file you're working on. Is there a way to modify my .vimrc such that the filename/path is always displayed? In your statusline, add a %F to display the full path: :help statusline " Add full file path to your existing statusline set statusline+=%F Note, %F will be the full path. To get a path relative to the working directory, use %f . If your statusline is not already visible, you may first need to configure it to be always visible, via laststatus=2 set laststatus=2 See :help laststatus for what the options mean. Normally, the statusline may be hidden, or

Is there a command in Vim/Vi to move the cursor to the end of a search highlight?

南笙酒味 提交于 2019-11-28 15:17:20
问题 Are there any commands in Vim/Vi to move within a selected search segment? For instance, if I search for a word, are there any commands to motion the cursor to the end of the highlighted segment? Say I have a word, "FishTaco" and I want to search for all instances of "Fish" and insert something after it. I know I could do a global replace, but what if I want to only make the change in a couple non-sequential instances? I could see where it would be convenient to be able to motion the cursor

How can I prepend text in the middle of the line to multiple lines in Vim?

瘦欲@ 提交于 2019-11-28 15:07:29
Say I have ten lines and I want to prepend text to some word that occurs in those lines? It does not have to be at the beginning of the line. From: sdfsd foo sdfsd sfsd foo fsdf sdfsdf foo sdfsdf to: sdfsd bar(foo sdfsd sfsd bar(foo fsdf sdfsdf bar(foo sdfsdf Is it also possible to not only prepend the bar( but actually surround foo with bar(foo) ? I would also like a quick way to append // comments to multiple lines (C-style comments). I use Vim/GVim 7.2. Go to the first foo , press Ctrl - v to enter visual block mode and press down until all the lines with foo are marked. Then press Shift -

vim line numbers - how to have them on by default?

廉价感情. 提交于 2019-11-28 15:05:26
I can :set number from within a file I'm editing but how can I have them always be on by default? Tim Pote Add set number to your .vimrc file in your home directory. If the .vimrc file is not in your home directory create one with vim .vimrc and add the commands you want at open. Here's a site that explains the vimrc and how to use it. abe312 To change the default setting to display line numbers in vi/vim: vi ~/.vimrc then add the following line to the file: set number Either we can source ~/.vimrc or save and quit by :wq , now vim session will have numbering :) sagar mahajan Terminal > su >

Anyone know of any (free / open source) VI integration for Visual Studio?

梦想与她 提交于 2019-11-28 14:37:25
问题 vi is for cool kids. 回答1: ViEmu - Not Free but great Vim emulation. Visual_Studio.vim - Allows you to manage visual studio from Vim. Using GVim as the Visual Studio Editor 回答2: After @joe's answer, Jared Parsons created the great VsVim. It's been featured on Visual Studio Gallery. It's a ready extension package. I downloaded it, ran the file and it worked out of the box. It's free, too. 回答3: Starting with Visual Studio 2010 you can use VsVim. It's a free extension available on the extension