Vim / To do

From WhyNotWiki

Jump to: navigation, search

Vim  edit   (Category  edit)


Contents

[edit] 5. Swap sides of operator

There should be a keyboard shortcut that takes the LHS of the operator over which the cursor is and swaps it with the RHS.

So if you put the cursor over ||, it would change this:

"development" || ENV["RAILS_ENV"]

into this:

ENV["RAILS_ENV"] || "development"

It would save about 20 keystrokes every time I used it -- and I'd use it probably at least once a day.

[edit] star_full.gif star_full.gif star_full.gif parenthesize command

Changes

include? nerd)

to

include?(nerd)

[edit] 8. Comment script should detect file type automatically

So if you're in an SQL file, it should only do SQL comments.

You should only have to tell it: single or multiline.

[edit] 8. Ruby syntax highlighting within =begin test block

Display it as Ruby code rather than as a comment.

[edit] 5. Map : and _ to something easier when editing ruby files

Since they use those symbols a lot and I don't want to do 2-key combinations when coding.

[edit] 5. Mks (:mksession "light")

Make light version of mks that just saves file names, not keymappings and everything! I want it to use my current ~/.vimrc not whatever .vimrc I happened to be using when I made the session!

[edit] 6. Autocomplete without pressing Ctrl-P?

Example: Start to type $GL and it can complete it with $GLOBALS

Or Ctrl-space?

[edit] 5. Pasting over other text erases your "" register!

It's frustrating when you copy text A, select text B, paste, select text C, and find that it pastes B rather than A!

Solution: Use

"0p

Or: map <C-p> to "0p ?

[edit] Automate constructor creation

From:

      def __init__(self, files, searchExpression, replaceExpression):

make:

           self.files = files
           self.searchExpression = searchExpression
           self.replaceExpression = replaceExpression

[edit] 5. Command to reformat SQL

Automatically fix formatting of an SQL query (could do it for other languages too)

Sometimes we come across a query that's formatted in an older style or just isn't tabbed correctly, like this:

SELECT c1, c2
                FROM a
 JOIN
  t2
...

would fix to:

SELECT
        c1,
        c2
        FROM
                        a
                JOIN
                        t2
...

[edit] 4. t mapping for substitution

t ->  :%s//gc

The t mapping (substitution) should only put a % before s if there is no selection.

Otherwise, it should use the selected range.


[edit] 4. I mapping to set paste and then insert

  • execute :set paste and then insert mode
  • should change back to :set nopaste when the insert command is done

[edit] 4. Jumping to line number

Should be able to do E (edit line):

:E file.php +33
:E file.php:33

to go to that line

If you put a :lineNumber and start on command line like this:

vim ./qualitysmith/lib/templateFunctions.php:33

it should jump to line 33

How? autocmd for fileNotFound error, perhaps.

[edit] 2. :Svnblame output to file in order to use vim's syntax highlighting

Instead of just outputting (with no syntax highlighting), the entire file, with lines that look sort of like:

  1245      tyler                       // Do page request
  1245      tyler                       $orderDetailURL = new Url($this->config->get("qualitysmith_backend_siteURL") . "order_detail.html");

, how about redirecting the svn diff to a file and showing in vim, so that we have vim's syntax highlighting, vim's search features, etc.?

But since it would be invalid syntax with the extra info, we might have to use sed to change the extra info into comments, like this:

/*  1245      tyler */                       // Do page request
/*  1245      tyler */                      $orderDetailURL = new Url($this->config->get("qualitysmith_backend_siteURL") . "order_detail.html");

[edit] ↓↓ Automate writing of getters/setters

Or find existing script/plugin

[edit] ↓↓ Commands to change between various PHP-in-HTML formats

HTML with PHP embedded:

        The price is "<?=$GLOBALS["price"]?>".

PHP heredoc string:

        <<<heredoc
        The price is "{$GLOBALS["price"]}".
heredoc;

PHP escaped string:

        " The price is \"{$GLOBALS["price"]}\""
Personal tools