-2

I've started using Vim for development and i'm really starting to like it a lot. But there are a few features of my usual editor (EditPlus) that i would like to have in Vim, maybe you can suggest ways of simulating or educating me on these?

  1. Global search of an entire project's source files for search term.
  2. Adding bookmarks to a file's source lines that i can jump to with a key press.
  3. Find all occurrences of word under cursor.
  4. Search and replace that lets me step through each for confirmation.
  5. Change line or selection to uppercase, lowercase, capitalize.
  6. Match brace/tag

P.S. I'm using Vim on Windows.

Gary Willoughby
  • 50,926
  • 41
  • 133
  • 199
  • 3
    So, I think that this is first several questions in one and second a lot of it is already covered in other SO questions. – EBGreen Jul 07 '11 at 18:16
  • 1
    Search across project: http://stackoverflow.com/questions/4804405/search-and-replace-in-vim-across-all-the-project-files – EBGreen Jul 07 '11 at 19:54
  • 1
    Jump to custom locations (one way...there are others): http://stackoverflow.com/questions/1580252/how-to-implement-own-tag-jump-in-vim-with-ctrl – EBGreen Jul 07 '11 at 19:56
  • 1
    Don't see a question specifically about 3, but gd will do it :) – EBGreen Jul 07 '11 at 20:01
  • 2
    Interactive find and replace: http://stackoverflow.com/questions/505848/interactive-search-replace-regex-in-vim – EBGreen Jul 07 '11 at 20:03
  • 1
    The Capitalization question is really itself multiple questions, but as an example, capitalize the first letter of the word under the cursor: http://stackoverflow.com/questions/3126500/vim-how-do-i-capitalize-the-first-letter-of-a-word – EBGreen Jul 07 '11 at 20:05

2 Answers2

3

1. Global search of an entire project's source files for search term.

  • :vim searches all files matching a wildcard.

2. Adding bookmarks to a file's source lines that i can jump to with a key press.

  • '' will swap your current cursor position and previous one
  • m* where * is a bookmark name (a-z) , '* jumps to the bookmark

3. Find all occurrences of word under cursor.

  • * searches forward
  • # searches backward
  • use :set hlsearch to highlight your search

4. Search and replace that lets me step through each for confirmation.

  • c flag to :substitute.

5. Change line or selection to uppercase, lowercase, capitalize.

  • ~ changes the case of the character under the cursor.

6. Match brace/tag

  • %. Requires enabling macros/matchit.vim or something similar for HTML tags support.

Check out making your own _vimrc to set default behaviors. Have fun vimming!

ZyX
  • 52,536
  • 7
  • 114
  • 135
phi
  • 1,513
  • 1
  • 15
  • 34
  • m[a-z] - identify a position within a particular file. For a global set of marks (across different files) use uppercase letters m[A-Z]. – Magnun Leno Jul 08 '11 at 19:44
  • ~ is good for swapping case, but 'U' change the selected text case to upper and 'u' change the selected text case to lower. – Magnun Leno Jul 08 '11 at 19:48
0

To add to what phi said:

1) :vimgrep /pattern/ **/*.c will search for pattern in all the .c files from the current directory down.

2) Use uppercase letters to set a mark that you can jump to from another file. e.g. mA to set a mark in the current file, then when editing a different file 'A will jump to the mark in the first file.

3) * and # search forward and backwards for the word under the cursor. n and N will repeat the previous search in the same or opposite direction. You can also use :g /pattern/ to see all the lines that match a pattern at once. There are also several plugins that will hide away (fold) all the lines that do not match a pattern.

5) gu<movement> and gU<movement> will change text to lower or upper case respectively. <movement> can be any vim movement, e.g. gU$ to make text from the current cursor position to the end of the line uppercase. There is also g~<movement> to switch the case of the text. Alternatively you can highlight the text and use u, U or ~ respectively.

Dave Kirby
  • 25,806
  • 5
  • 67
  • 84
  • 2
    If you want to add to what Phi said, shouldn't you...you know...add to what Phi said. Isn't that one of the intended behaviors of a community wiki answer? – EBGreen Jul 07 '11 at 20:10