diff options
author | Kenny Ballou <kballou@devnulllabs.io> | 2018-01-30 16:30:09 -0700 |
---|---|---|
committer | Kenny Ballou <kballou@devnulllabs.io> | 2018-08-19 08:13:43 -0600 |
commit | bb50d766f7a866538961bca7ed262375a0e3ffd0 (patch) | |
tree | 5e9eb90c6e7d38841d2441c6617429e7ce983047 | |
parent | 89cbde1e8c4be21d77fb9db2c670a7d324f9f521 (diff) | |
download | blog.kennyballou.com-bb50d766f7a866538961bca7ed262375a0e3ffd0.tar.gz blog.kennyballou.com-bb50d766f7a866538961bca7ed262375a0e3ffd0.tar.xz |
vim-tips-2015-03-17 post conversion
-rw-r--r-- | content/blog/vim_tips_2015_03_17.markdown | 85 | ||||
-rw-r--r-- | posts/vim-tips-2015-03-17.org | 90 |
2 files changed, 90 insertions, 85 deletions
diff --git a/content/blog/vim_tips_2015_03_17.markdown b/content/blog/vim_tips_2015_03_17.markdown deleted file mode 100644 index 7bdb57d..0000000 --- a/content/blog/vim_tips_2015_03_17.markdown +++ /dev/null @@ -1,85 +0,0 @@ ---- -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<movement>`. - -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<movement>` 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: - - :<starting line>,<ending line>s/foo/bar[/g] - -End today's kicker: changing from a line to the end of the file: - - :<start>,$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] diff --git a/posts/vim-tips-2015-03-17.org b/posts/vim-tips-2015-03-17.org new file mode 100644 index 0000000..f0d8f20 --- /dev/null +++ b/posts/vim-tips-2015-03-17.org @@ -0,0 +1,90 @@ +#+TITLE: Vim Tips 2015-03-17 +#+DESCRIPTION: First vim tip post of a series of unknown size +#+TAGS: Vim +#+TAGS: Tips and Tricks +#+TAGS: Editors +#+DATE: 2015-03-17 +#+SLUG: vim-tips-2015-03-17 +#+LINK: vim-wiki-folding http://vim.wikia.com/wiki/Folding +#+LINK: vim-wiki-ranges http://vim.wikia.com/wiki/Ranges +#+LINK: zzapper-vim-tips http://zzapper.co.uk/vimtips.html + +#+BEGIN_PREVIEW +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. +#+END_PREVIEW + +** Folds + +When using manual folding, creating a fold in Vim is as easy as one command: + +In normal mode, ~zf<movement>~. + +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<movement>~ 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-folding][Vim wiki page]] 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: + +#+BEGIN_EXAMPLE sed +:s/foo/bar +#+END_EXAMPLE + +All occurrences: + +#+BEGIN_EXAMPLE sed + :s/foo/bar/g +#+END_EXAMPLE + +Entire file, first occurrence: + +#+BEGIN_EXAMPLE sed + :%s/foo/bar/ +#+END_EXAMPLE + +Entire file, all occurrences: + +#+BEGIN_EXAMPLE sed + :%s/foo/bar/g +#+END_EXAMPLE + +Now for something completely different, specific ranges: + +#+BEGIN_EXAMPLE + :<starting line>,<ending line>s/foo/bar[/g] +#+END_EXAMPLE + +End today's kicker: changing from a line to the end of the file: + +#+BEGIN_EXAMPLE + :<start>,$s/foo/bar[/g] +#+END_EXAMPLE + +Visit [[vim-wiki-ranges][Vim Ranges]] to view more information about the ranges +available in Vim. + +** References + +- [[zzapper-vim-tips][Vim Tips]] + +- [[vim-wiki-folding][Vim Wikia: Folding]] + +- [[vim-wiki-ranges][Vim Wikia: Ranges]] |