<?xml version="1.0" encoding="utf-8" standalone="yes"?><?xml-stylesheet href="/rss.xsl" type="text/xsl"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/"><title>Vim on Hyteck</title><link href="https://hyteck.de/categories/vim/"/><generator>Hugo -- gohugo.io</generator><language>en-us</language><id>https://hyteck.de/categories/vim/</id><updated>2022-05-25T15:15:55+02:00</updated><link href="https://hyteck.de/categories/vim/index.xml" rel="self" type="application/rss+xml"/><entry><title>Vim shortcuts to execute current line</title><link href="https://hyteck.de/post/easy_execute_in_vim/" type="application/octet-stream"/><updated>2022-05-25T15:15:55+02:00</updated><id>https://hyteck.de/post/easy_execute_in_vim/</id><author><name>Julian-Samuel Gebühr</name></author><content type="html"> &lt;p>I recently had to write a lot of SQL code and thought it would be very neat to have some vim shortcuts to execute the current line or the current command.
I want to share this with everyone as the second command needed some try-and-error on my part.&lt;/p>
&lt;p>Adding the following to &lt;code>~/.vimrc&lt;/code>&lt;/p>
&lt;pre tabindex="0">&lt;code>map &amp;lt;F2&amp;gt; :.w !psql&amp;lt;CR&amp;gt;
map &amp;lt;F3&amp;gt; :.,/;/w !psql&amp;lt;CR&amp;gt;
map &amp;lt;F4&amp;gt; :w !psql&amp;lt;CR&amp;gt;
&lt;/code>&lt;/pre>&lt;p>will enable you to execute the current line in psql with &lt;code>F2&lt;/code>. &lt;code>F3&lt;/code> executes the current line and the next lines until a&lt;code>;&lt;/code>.
&lt;code>F4&lt;/code> executes the whole file.&lt;/p>
&lt;p>This can easily adapted to your needs. If you have any questions or improvemnts feel free to use the chat below.&lt;/p>
&lt;script type="text/javascript" src="https://latest.cactus.chat/cactus.js">&lt;/script>
&lt;link rel="stylesheet" href="https://latest.cactus.chat/style.css" type="text/css">
&lt;div id="comment-section">&lt;/div>
&lt;script>
initComments({
node: document.getElementById("comment-section"),
defaultHomeserverUrl: "https://matrix.cactus.chat:8448",
serverName: "cactus.chat",
siteName: "hyteck",
commentSectionId: "vim-shortcuts"
})
&lt;/script></content></entry></feed>