GVimPortable - носим Vim на флешке
К вопросу о выборе правильного редактора: пользователи Windows, обратите внимание на знаменитый редактор Vim, а точнее — на его “переносную” версию под Windows: GVim Portable.
И не забудьте посетить сайт vim online, содержащий хорошую подборку документации по Vim.
Ссылки на дружественные vim'у ресурсы
To find and replace one or more occurences of a given text pattern with a new text string, use the s[ubstitute] command.
There are a variety of options, but these are what you most probably want:
:%s/foo/bar/g | find each occurance of 'foo' and replace it with 'bar' without asking for confirmation | |
:%s/foo/bar/gc | find each occurance of 'foo' and replace it with 'bar' asking for confirmation first | |
:%s/<foo>/bar/gc | find (match exact word only) and replace each occurance of 'foo' with 'bar' | |
:%s/foo/bar/gci | find (case insensitive) and replace each occurance of 'foo' with 'bar' | |
:%s/foo/bar/gcI | find (case sensitive) and replace each occurance of 'foo' with 'bar' |
For a full description and some more interesting examples of the substitute command refer to
:help substitute
See also:
:help cmdline-ranges
:help pattern
:help gdefault
Tip #1501 - substitute last search : vim online
Замена результатов предыдущего поиска:
/ищем-что-то :%s//меняем-на-другое/gВ итоге будет произведена замена
ищем-что-то
на строку меняем-на-другое
. Плюс в том, что не надо дважды вводить выражение для поиска, и исключается возможность ошибки в написании.
Copy and paste text with vi or vim
The command 'Y' or 'yy' copies (yanks) one or more lines. To copy one line, two lines, 10 lines, and all lines to the end of the file, respectively:
Y 2Y 10Y yG
To paste the text contained in the buffer above (uppercase P) or below the current cursor position (lowercase p), respectively:
P p
It is also possible to yank text within a line. The following commands yank text from the current cursor position to the end of the word and the end of the line, respectively:
yw y$
The same commands paste the text within a line. Lower case p pastes after the cursor position and upper case P pastes before.
Paste will also work with deleted text, either lines or parts of lines. Be careful not to execute any other commands prior to pasting as this will empty the buffer.
:set numberor shorter:
:set nu
:nmap <C-N><C-N> :set invnumber <CR>