hyteck-blog/content/post/easy_execute_in_vim.md

839 B

title date draft image tags categories
Vim shortcuts to execute current line 2022-05-25T15:15:55+02:00 false uploads/logos/vim.png
vim
vim
English

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.

Adding the following to ~/.vimrc

map <F2> :.w !psql<CR>
map <F3> :.,/;/w !psql<CR>
map <F4> :w !psql<CR>

will enable you to execute the current line in psql with F2. F3 executes the current line and the next lines until a;. F4 executes the whole file.

This can easily adapted to your needs. If you have any questions or improvemnts feel free to use the chat below.

{{< chat vim-shortcuts >}}