The macro commands below are from the _vimrc file I use to customize Vim under Cygwin running on Windows 10. Note that characters in red below indicate control characters. ^M is control-M which is the code produced by the Enter key on Windows keyboards. ^[ is the code produced by the Escape key.
One of the things which saves time for me is having the ability to easily copy and paste lines from one file being edited to another. These macros help me accomplish that.
" set temporary yank and paste filename
let @p="c:\\Users\\ViUser\\Documents\\vim\\vim.tmp"
" mark beginning of a line block (uses the a mark)
map \m ma
" yank lines to temp file (from mark to cursor pos. - uses b mark, b buffer)
map \Y :'a,.w! p^Mmb"ay'a`b
" paste lines previously yanked or deleted to temp file at cursor pos.
map \P k:r p^M
Another thing I do frequently is edit log files and search for my initials which I include in any log messages I add. The macro below searches the log file being edited for the letters "TBD" and removes all other text. Just remember to quit without saving or use the Vim undo command.
map \gt ^[ggVG!grep TBD^M
No comments:
Post a Comment