Skip to content

Instantly share code, notes, and snippets.

@JadedEvan
Created September 22, 2011 18:24

Revisions

  1. JadedEvan revised this gist Aug 7, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions vim-notes.mdown
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,8 @@ Sets the offset when scrolling through a document. A value of 30 will keep a mar

    Additional buffer settings

    * `:set list` - show invisible characters
    * `:set nolist` - hide invisible characters
    * `:set list` - show invisible characters
    * `:set nolist` - hide invisible characters

    ### Functions

  2. JadedEvan revised this gist Aug 7, 2012. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions vim-notes.mdown
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,11 @@

    Sets the offset when scrolling through a document. A value of 30 will keep a marginal amount of space while scrolling, a value of 999 will keep the cursor centered in the screen, a value of 0 restores Vim's default behavior. All of the above can be added to your *~/.vimrc* file to set editor defaults. [Vim wikia - scroll centering](http://vim.wikia.com/wiki/Keep_your_cursor_centered_vertically_on_the_screen)

    Additional buffer settings

    * `:set list` - show invisible characters
    * `:set nolist` - hide invisible characters

    ### Functions

    :let i=1 | %g/fixture_\d\=$/s/fixture_\d\=$/\=i/ |let i=i+1
  3. JadedEvan revised this gist Apr 26, 2012. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions vim-notes.mdown
    Original file line number Diff line number Diff line change
    @@ -31,6 +31,10 @@ Delete all text in the line after matching first word in lines 12-21.

    Useful command for removing the ^M characters that come from Windows/DOS file encodings. \#1 saves the file, \#2 edits file again, using dos file format ('fileformats' is ignored). \#3 - buffer will use LF-only line endings when written. \#4 write buffer using unix (LF-only) line endings.

    Alternately, to remove `^M` characters:

    :%s/<ctrl-v><enter>/\r/g

    ### Substitutions and Files

    :arg some/path/**/*.mdown
  4. JadedEvan revised this gist Nov 11, 2011. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion vim-notes.mdown
    Original file line number Diff line number Diff line change
    @@ -36,4 +36,8 @@ Useful command for removing the ^M characters that come from Windows/DOS file en
    :arg some/path/**/*.mdown
    :argdo %s/some_expression_here/some_replacement_here/g | update

    Searches recursively sub directories in `some/path` for files named *.markdown, then performs the substitution command provided in the second line. You can add the /gc flag if you want to confirm your substitutions. Will perform operation on all matching files.
    Searches recursively sub directories in `some/path` for files named *.markdown, then performs the substitution command provided in the second line. You can add the /gc flag if you want to confirm your substitutions. Will perform operation on all matching files.

    $ vim "+%s/foo/bar/g" "+wq" foo.txt

    Command line invocation of vim. Any argument passed in with a plus in front of the arguments will be run in Vim's ex mode. The command above will replace all occurances of "foo" with "bar" and write the changes. Note that any valid Vim ex mode command can be run this way.
  5. JadedEvan revised this gist Nov 11, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions vim-notes.mdown
    Original file line number Diff line number Diff line change
    @@ -33,7 +33,7 @@ Useful command for removing the ^M characters that come from Windows/DOS file en

    ### Substitutions and Files

    :arg *.mdown
    :arg some/path/**/*.mdown
    :argdo %s/some_expression_here/some_replacement_here/g | update

    Searches current directory for any file matching *.markdown, then performs the substitution command provided in the second line. You can add the /gc flag if you want to confirm your substitutions. Will perform operation on all matching files.
    Searches recursively sub directories in `some/path` for files named *.markdown, then performs the substitution command provided in the second line. You can add the /gc flag if you want to confirm your substitutions. Will perform operation on all matching files.
  6. JadedEvan revised this gist Sep 24, 2011. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion vim-notes.mdown
    Original file line number Diff line number Diff line change
    @@ -29,4 +29,11 @@ Delete all text in the line after matching first word in lines 12-21.
    :setlocal ff=unix
    :w

    Useful command for removing the ^M characters that come from Windows/DOS file encodings. \#1 saves the file, \#2 edits file again, using dos file format ('fileformats' is ignored). \#3 - buffer will use LF-only line endings when written. \#4 write buffer using unix (LF-only) line endings.
    Useful command for removing the ^M characters that come from Windows/DOS file encodings. \#1 saves the file, \#2 edits file again, using dos file format ('fileformats' is ignored). \#3 - buffer will use LF-only line endings when written. \#4 write buffer using unix (LF-only) line endings.

    ### Substitutions and Files

    :arg *.mdown
    :argdo %s/some_expression_here/some_replacement_here/g | update

    Searches current directory for any file matching *.markdown, then performs the substitution command provided in the second line. You can add the /gc flag if you want to confirm your substitutions. Will perform operation on all matching files.
  7. @invalid-email-address Anonymous revised this gist Sep 22, 2011. 1 changed file with 28 additions and 1 deletion.
    29 changes: 28 additions & 1 deletion vim-notes.mdown
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,32 @@
    ### Buffer Settings

    :set scrolloffset=30
    :set scrolloffset=999
    :set so=0

    Sets the offset when scrolling through a document. A value of 30 will keep a marginal amount of space while scrolling, a value of 999 will keep the cursor centered in the screen, a value of 0 restores Vim's default behavior. [Vim wikia - scroll centering](http://vim.wikia.com/wiki/Keep_your_cursor_centered_vertically_on_the_screen)
    Sets the offset when scrolling through a document. A value of 30 will keep a marginal amount of space while scrolling, a value of 999 will keep the cursor centered in the screen, a value of 0 restores Vim's default behavior. All of the above can be added to your *~/.vimrc* file to set editor defaults. [Vim wikia - scroll centering](http://vim.wikia.com/wiki/Keep_your_cursor_centered_vertically_on_the_screen)

    ### Functions

    :let i=1 | %g/fixture_\d\=$/s/fixture_\d\=$/\=i/ |let i=i+1

    Matches a pattern throughout the document, increments the number.

    ### File Manipulation

    :norm jdd

    Delete every other line

    12,21s/^\(\<\w\+\>\).*$/\1/g

    Delete all text in the line after matching first word in lines 12-21.

    ### File Conversion

    :update
    :e ++ff=dos
    :setlocal ff=unix
    :w

    Useful command for removing the ^M characters that come from Windows/DOS file encodings. \#1 saves the file, \#2 edits file again, using dos file format ('fileformats' is ignored). \#3 - buffer will use LF-only line endings when written. \#4 write buffer using unix (LF-only) line endings.
  8. @invalid-email-address Anonymous created this gist Sep 22, 2011.
    5 changes: 5 additions & 0 deletions vim-notes.mdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    :set scrolloffset=30
    :set scrolloffset=999
    :set so=0

    Sets the offset when scrolling through a document. A value of 30 will keep a marginal amount of space while scrolling, a value of 999 will keep the cursor centered in the screen, a value of 0 restores Vim's default behavior. [Vim wikia - scroll centering](http://vim.wikia.com/wiki/Keep_your_cursor_centered_vertically_on_the_screen)