Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts

Friday, September 2, 2011

Forcing Vim's syntax highlighting (for odd file extensions)

I often tend to keep backup copies of my C/C++ source files with odd extensions (i.e. something that does not end with CC or C). If these files are opened with Vim, they wouldn't be recognized as they should, which means my CTAGS extension and colored syntax highlighting would both refrain to work. The quick solution to this problem is to tell Vim explicitly about the file type. Here is how one can do it:
:setfiletype c
More information on it, as always:
:help setfiletype

Monday, September 27, 2010

Executing commands in shell and accepting the output in Vim

Source: http://www.linux.com/archive/feed/57727

:r ! ls

It is also possible to select certain lines in Vim with v, V or ctrl+v and send it to a Bash command. The selected lines (input for Bash command) will be replaced by the output from Bash. Typical line number specification is also allowed.

:5,7 ! xargs ls -alh

Wednesday, January 20, 2010

Pasting text in Vim from webpages

Vim auto-indents texts/code-snippets while pasting from websites. The trick is to take vim in "paste" mode to stop auto-indenting:

while pasting ...
:set paste
when pasting is doen ...
:set nopaste

Wednesday, June 11, 2008

Vim freezes with Ctrl+S

lol ... now this is a very strange and funny problem. Most of us are used to ctrl+s for saving files, but on vim it just freezes everything. Specially if you are on a ssh session, have just added 100 lines of code to your cool new application, ctrl+s can effectively ruin all the fun all of a sudden. Well the solution to this problem was not very complicated, try pressing ctrl+q ;)

Well, found the solution to this problem somewhere here :: http://vimdoc.sourceforge.net/cgi-bin/vimfaq2html3.pl#32.1. And this is what it says ::

Many terminal emulators and real terminal drivers use the CTRL-S key to
stop the data from arriving so that you can stop a fast scrolling display
to look at it (also allowed older terminals to slow down the computer so
that it did not get buffer overflows).  You can start the output again by
pressing the CTRL-Q key.

When you press the CTRL-S key, the terminal driver will stop sending the
output data. As a result of this, it will look like Vim is hung. If you
press the CTRL-Q key, then everything will be back to normal.

You can turn of the terminal driver flow control using the 'stty' command:

$ stty -ixon -xoff

or, you can change the keys used for the terminal flow control, using the
following commands:

$ stty stop 
$ stty start 

Tuesday, April 29, 2008

My SuPeR-DuPeR vim config ;)


runtime! debian.vim
syntax on

if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif

if has("autocmd")
filetype indent on
endif

set showcmd
set showmatch
set ignorecase
set smartcase
set incsearch
set autowrite
set hidden

if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif


set number
set hlsearch
colorscheme slate