From c8664eb10a8c33dfbe83d112f791e3ab16cb32bb Mon Sep 17 00:00:00 2001 From: kballou Date: Mon, 16 Mar 2015 23:47:54 -0600 Subject: Add First Vim Tips Post --- blag/content/blog/vim_tips_2015_03_17.markdown | 85 ++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 blag/content/blog/vim_tips_2015_03_17.markdown (limited to 'blag') diff --git a/blag/content/blog/vim_tips_2015_03_17.markdown b/blag/content/blog/vim_tips_2015_03_17.markdown new file mode 100644 index 0000000..7bdb57d --- /dev/null +++ b/blag/content/blog/vim_tips_2015_03_17.markdown @@ -0,0 +1,85 @@ +--- +title: "Vim Tips 2015-03-17" +description: "First Vim tip post of a series of unknown size" +tags: + - "Vim" + - "Tips and Tricks" + - "Editors" +date: "2015-03-17" +categories: + - "Development" + - "Editors" + - "Tools" +slug: "vim-tips-2015-03-17" +--- + +This is the start of a series of posts about better Vim usage. It's yet to be +determined how often and how frequent this will run, but expect more than just +this first post. + +## Folds ## + +When using manual folding, creating a fold in Vim is as easy as one command: + +In normal mode, `zf`. + +For example, while in Java code and on a Method opening curly brace, type +`zf%`. + +And a fold is now created around that method. You can toggle it open and closed +with `za`, you can also open it with `zo` and you can close it with `zc`. + +Similarly, to remove a fold created by `zf`, use `zd` to remove +folds. + +From the above example, while in normal mode, typing `zd%` will remove the fold +for the method's block. + +For more information about folding and the other modes, visit the [Vim wiki +page][2] on folding. + +## Substitution Range ## + +Here are some more explicit examples of the range options provided when doing +substitutions: + +To substitute the first occurrence of the pattern in the current line: + + :s/foo/bar + +All occurrences: + + :s/foo/bar/g + +Entire file, first occurrence: + + :%s/foo/bar/ + +Entire file, all occurrences: + + :%s/foo/bar/g + +Now for something completely different, specific ranges: + + :,s/foo/bar[/g] + +End today's kicker: changing from a line to the end of the file: + + :,$s/foo/bar[/g] + +Visit [Vim Ranges][3] to view more information about the ranges available in +Vim. + +## References ## + +[1]: http://zzapper.co.uk/vimtips.html + +* [Vim Tips][1] + +[2]: http://vim.wikia.com/wiki/Folding + +* [Vim Wikia: Folding][2] + +[3]: http://vim.wikia.com/wiki/Ranges + +* [Vim Wikia: Ranges][3] -- cgit v1.2.1