Home |  MySQL Buzz |  FAQ |  Feeds |  Submit your blog feed |  Feedback |  Archive |  Aggregate feed RSS 2.0 English Deutsch Español Français Italiano 日本語 Русский Português 中文
Showing entries 1 to 4

Displaying posts with tag: vim (reset)

Executing MySQL queries within VIM
+1 Vote Up -0Vote Down

I haven’t been using vim for very long, but I’ve gotten over the initial learning curve of getting used to the different editing modes. With some help from the guys in #vim on irc.freenode.net, I managed to get this gem:

map <C-d> :call SwitchDB()<CR>
:function SwitchDB()
: let g:current_db = input("Database > ")
:endfunction

map <C-m> :call Doquery()<CR>
:function Doquery()
: if !exists("g:current_db")
: call SwitchDB()
: endif
: let query_string = input(g:current_db . " > " )
: if query_string != ""
: exe "!mysql " . g:current_db . " -e \"" . escape(query_string, '"') . "\""
: endif
:endfunction

Control-m to execute a query. Control-d to switch databases. It’ll prompt you the first time.

How To Add A File Extension To vim Syntax Highlighting
+1 Vote Up -0Vote Down

Today I was asked a question about defining custom extensions for vim syntax highlighting such that, for example, vim would know that example.lmx is actually of type xml and apply xml syntax highlighting to it. I know vim already automatically does it not just based on extension but by looking for certain strings inside the text, like

After digging around I found the solution. Add the following to ~/.vimrc (the vim configuration file):

1
2
3
syntax on
filetype on
au BufNewFile,BufRead *.lmx set filetype=xml

After applying it, my .lmx file is highlighted:

  [Read more...]
Trip to Zurich
+0 Vote Up -0Vote Down
I spent Thursday and Friday in Zurich, Switzerland visiting my friends Marcus and Caitlin and attending the Google Open Source Jam.

On Thursday, I arrived in the early afternoon in Zurich. Getting to Zurich from Siegburg is easy and takes less than five hours as there is a direct ICE connection to Basel and from there it is just one more stop with an IC or

  [Read more...]
MySQL syntax highlighting in Vim
+1 Vote Up -0Vote Down
I didn't know such a thing exists.
kostja@bodhi:/usr/share/vim/vim70/syntax> ls -al mysql.vim 
-rw-r--r-- 1 root root 16078 2006-05-24 20:16 mysql.vim

kostja@bodhi:/usr/share/vim/vim70/syntax> head -7 mysql.vim 
" Vim syntax file
" Language:     mysql
" Maintainer:   Kenneth J. Pronovici <pronovic@ieee.org>
" Last Change:  $Date: 2004/06/13 20:12:39 $
" Filenames:    *.mysql
" URL:		ftp://cedar-solutions.com/software/mysql.vim
" Note:		The definitions below are taken from the mysql user manual as of April 2002, for version 3.23
To enable it in the editor:
:set filetype=mysql

Or, in your .vimrc to highlight all .sql and .test files:
if has("autocmd")
        autocmd BufRead *.sql set filetype=mysql      
        autocmd BufRead *.test set filetype=mysql
endif
Showing entries 1 to 4

Planet MySQL © 1995, 2014, Oracle Corporation and/or its affiliates   Legal Policies | Your Privacy Rights | Terms of Use

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.