Vim Tips Wiki
Edit Page
We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 14: Line 14:
   
 
==Move to next variable on current line==
 
==Move to next variable on current line==
PHP variables start with '<code>$</code>', for example, <code>$var</code>. In normal mode, type <code>f$</code> to jump forwards to the next variable; repeat by pressing <code>;</code> (next, in same direction), or <code>,</code> (next, in opposite direction). Typing <code>F$</code> finds '<code>$</code>' in the backwards direction. {{help|f}}
+
PHP variables start with '<tt>$</tt>', for example, <tt>$var</tt>. In normal mode, type <tt>f$</tt> to jump forwards to the next variable; repeat by pressing <tt>;</tt> (next, in same direction), or <tt>,</tt> (next, in opposite direction). Typing <tt>F$</tt> finds '<tt>$</tt>' in the backwards direction. {{help|f}}
   
If you do this a lot, you may want to use the following mappings in your [[vimrc]] so you can press <code>L</code> to jump to the next variable, or <code>H</code> to jump to the previous variable:
+
If you do this a lot, you may want to use the following mappings in your [[vimrc]] so you can press <tt>L</tt> to jump to the next variable, or <tt>H</tt> to jump to the previous variable:
 
<pre>
 
<pre>
 
noremap L f$
 
noremap L f$
Line 23: Line 23:
   
 
==Fix 4 instead of $==
 
==Fix 4 instead of $==
It's easy to press <code>4</code> instead of <code>$</code>, resulting in code like this:
+
It's easy to press <tt>4</tt> instead of <tt>$</tt>, resulting in code like this:
 
<pre>
 
<pre>
 
$var = "sometext"; echo 4var;
 
$var = "sometext"; echo 4var;
 
</pre>
 
</pre>
   
With the following map, you can quickly fix this problem by typing <code>\4</code> while the cursor is still on the same line, after the '4' (this assumes the default backslash <Leader> key):
+
With the following map, you can quickly fix this problem by typing <tt>\4</tt> while the cursor is still on the same line, after the '4' (this assumes the default backslash <Leader> key):
 
<pre>
 
<pre>
 
nnoremap <Leader>4 F4r$A
 
nnoremap <Leader>4 F4r$A
Line 40: Line 40:
   
 
==Abbreviations to insert debug code==
 
==Abbreviations to insert debug code==
The following abbreviations provide an easy way to enter debug code. In insert mode, type <code>phpb</code> then the name of a variable to be displayed.
+
The following abbreviations provide an easy way to enter debug code. In insert mode, type <tt>phpb</tt> then the name of a variable to be displayed.
 
<pre>
 
<pre>
 
iab phpb exit("<hr>Debug ");
 
iab phpb exit("<hr>Debug ");
Line 46: Line 46:
 
</pre>
 
</pre>
   
These display any variables that have been yanked into register <code>a</code>:
+
These display any variables that have been yanked into register <tt>a</tt>:
 
<pre>
 
<pre>
 
iab phpbb exit("<hr>Debug <C-R>a ");
 
iab phpbb exit("<hr>Debug <C-R>a ");
Line 52: Line 52:
 
</pre>
 
</pre>
   
<code>Var_dump</code> is used for displaying arrays.
+
<tt>Var_dump</tt> is used for displaying arrays.
   
 
This displays all defined variables:
 
This displays all defined variables:
Line 75: Line 75:
 
</pre>
 
</pre>
   
In the above, the <code>c</code> flag prompts for confirmation of each change.
+
In the above, the <tt>c</tt> flag prompts for confirmation of each change.
   
 
==See also==
 
==See also==
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)