vi

Replacing quote marks around strings in Vim?

↘锁芯ラ 提交于 2019-12-02 15:11:44
I have something akin to <Foobar Name='Hello There'/> and need to change the single quotation marks to double quotation marks. I tried :s/\'.*\'/\"\0\" but it ended up producing <Foobar Name="'Hello There'"/> . Replacing the \0 with \1 only produced a blank string inside the double quotes - is there some special syntax I'm missing that I need to make only the found string ("Hello There") inside the quotation marks assign to \1 ? You need to use groupings: :s/\'\(.*\)\'/\"\1\" This way argument 1 (ie, \1) will correspond to whatever is delimited by \( and \). There's also surround.vim , if you

how to change editor behavior in intellij idea

梦想的初衷 提交于 2019-12-02 15:04:16
I have installed IntelliJIdea 14.0.2 just now. I do not know its default editor but it is opening my source files in vi option now. So, not letting me do default action like Ctrl + v , Ctrl + d which was present before and I used to like it. So, how to change this behavior like present in sublime - editors ? If you don't need vi keybindings, uninstall the IdeaVIM plugin. disable below option in menu bar. Tools -> VimEmulator(Ctrl + Alt + V) If you don't want to uninstall vi, you can either turn it off, like @redredtokki states (Tools > VimEmulator), or Change the Ctrl-X and Ctrl-V keys in File

Find and Replace within selection in `vi`

[亡魂溺海] 提交于 2019-12-02 15:03:34
How do I do a Find and Replace within a selection in vi ? Select the text in visual mode (I assume that's what you're doing), then press : to start typing a command, you'll see something like this appear in the command line: :'<,'> That means that the command will apply to the selection. Then type s/search/replace/ and hit enter. (Add a g after the third slash if you want to replace all matches, and a c if you want a confirmation for every replace) Most of the other solutions suggested here work over the ENTIRE line in which the selection occurs, which may not be what you want. To search and

How do I “source” something in my .vimrc file?

女生的网名这么多〃 提交于 2019-12-02 14:34:21
I've been working on expanding my vim-foo lately and I've run across a couple of plugins ( autotag.vim for example) that require them to be "sourced" in my .vimrc file. What exactly does this mean and how do I do it? Whaledawg Sourcing a file is 'executing' it. Essentially, each line of the file is considered a command. Sourcing it is the same as typing each command in order. You source with the command :source (usually shortened to :so ). So if you source myStuff.vim :so myStuff.vim and if myStuff.vim contained these lines set xx iI just intersted this<C-]> set yy bbbb4dw It's the same as if

Search for string and get count in vi editor

亡梦爱人 提交于 2019-12-02 14:16:06
I want to search for a string and find the number of occurrences in a file using the vi editor. Kevin Beck :g/xxxx/d This will delete all the lines with pattern, and report how many deleted. Undo to get them back after. THE way is :%s/pattern//gn You need the n flag. To count words use: :%s/\i\+/&/gn and a particular word: :%s/the/&/gn See count-items documentation section. If you simply type in: %s/pattern/pattern/g then the status line will give you the number of matches in vi as well. :%s/string/string/g will give the answer. (similar as Gustavo said, but additionally: ) For any previously

Tabs and spaces in vim

随声附和 提交于 2019-12-02 13:51:51
How do I prevent vim from replacing spaces with tabs when autoindent is on? An example: if I have two tabs and 7 spaces in the beginning of the line, and tabstop=3 , and I press Enter, the next line has four tabs and 1 space in the beginning, but I don't want that... user11211 It is perhaps a good idea not to use tabs at all. :set expandtab If you want to replace all the tabs in your file to 3 spaces (which will look pretty similar to tabstop=3 ): :%s/^I/ / (where ^I is the TAB character) From the VIM online help: 'tabstop' 'ts' number (default 8) local to buffer Number of spaces that a <Tab>

/etc/apt/sources.list\" E212: Can't open file for writing

百般思念 提交于 2019-12-02 13:50:37
I am trying to edit sources.list using vi editor but getting the following error while saving the file: /etc/apt/sources.list" E212: Can't open file for writing Zsolt Botykai For some reason the file you are writing to cannot be created or overwritten. The reason could be that you do not have permission to write in the directory or the file name is not valid. Vim has a builtin help system. I just quoted what it says to :h E212 . You might want to edit the file as a superuser as sudo vim FILE . Or if you don't want to leave your existing vim session (and now have proper sudo rights), you can

How to move one word left in vi editor

久未见 提交于 2019-12-02 13:49:18
I use shortcut w to move the cursor one word right, is there any shortcut to move a word left? Wazery use b to move back one word use w to move forward one word and here is a cheat sheet that might be useful for you Source: http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html It's b . You can see other motions here: http://vimdoc.sourceforge.net/htmldoc/motion.html#word-motions Generally a Vim command is consisted of count action motion Where: count is number of times you want it to execute, default is 1 action is obviously an action: d for delete, c for change, default is empty

Will Emacs make me a better programmer? [closed]

孤人 提交于 2019-12-02 13:48:35
Steve Yegge wrote a comment on his blog : All of the greatest engineers in the world use Emacs. The world-changer types. Not the great gal in the cube next to you. Not Fred, the amazing guy down the hall. I'm talking about the greatest software developers of our profession, the ones who changed the face of the industry. The James Goslings, the Donald Knuths, the Paul Grahams, the Jamie Zawinskis, the Eric Bensons. Real engineers use Emacs. You have to be way smart to use it well, and it makes you incredibly powerful if you can master it. Go look over Paul Nordstrom's shoulder while he works

In vim, how do I go back to where I was before a search?

荒凉一梦 提交于 2019-12-02 13:47:20
Programming in vim I often go search for something, yank it, then go back to where I was, insert it, modify it. The problem is that after I search and find, I need to MANUALLY find my way back to where I was. Is there an automatic way to go back to where I was when I initiated my last search? Ctrl + O takes me to the previous location. Don't know about location before the search. Edit: Also, ` . will take you to the last change you made. Max Cantor Use `` to jump back to the exact position you were in before you searched/jumped, or '' to jump back to the start of the line you were on before