Skip to content

Instantly share code, notes, and snippets.

@h1mesuke
h1mesuke / search.vim
Created October 18, 2010 05:02
Vim - My vimrc snippet for searching for texts; ver.2
"---------------------------------------
" Search
set incsearch nohlsearch
set noignorecase nosmartcase
nnoremap [Space]hl :<C-u>call util#toggle_option("hlsearch")
cnoremap <expr> / getcmdtype() == '/' ? '\/' : '/'
cnoremap <expr> ? getcmdtype() == '?' ? '\?' : '?'
@h1mesuke
h1mesuke / commentout.vim
Created October 15, 2010 01:55
Vim - My vimrc snippet for commenting-out source codes; ver.3
"-----------------------------------------------------------------------------
" Comment-out
let g:commentout_schemes = {
\ '#': {
\ 1: { 'type': 'lhs', 'leader': '#' },
\ },
\ 'c': {
\ 1: { 'type': 'wrap', 'leader': '/*', 'trailer': '*/' },
\ 3: { 'type': 'block', 'leader': '/*', 'trailer': '*/' },
@h1mesuke
h1mesuke / util.vim
Created October 14, 2010 08:09
Vim - My autload/util.vim
" NOTE: THIS FILE CONTAINS MANY EXPERIMENTAL CODES!
"-----------------------------------------------------------------------------
" Abbrev
function! util#abbrev(words)
let table = {}
let seen = {}
for word in a:words
let abbrev = substitute(word, '.$', '', '')
@h1mesuke
h1mesuke / gist:625511
Created October 14, 2010 03:28
Vim - My vimrc snippet for replacing texts; ver.2
"---------------------------------------
" Replace
set report=0
xnoremap S <Nop>
" replace the user input in the current line
nnoremap s :<C-u>s//g "<Left><Left><Left><Left>
" replace the cword in the current line
@h1mesuke
h1mesuke / escape_selection.vim
Created September 18, 2010 15:34
Vim - My vimrc snippet for escaping the selection in various schemes.
"---------------------------------------
" Escape
" html
xnoremap <silent> eh :<C-u>call <SID>selection_escape_html()<CR>
xnoremap <silent> uh :<C-u>call <SID>selection_unescape_html()<CR>
function! s:selection_escape_html()
call util#filter_selection("ruby -rcgi -pe '$_ = CGI.escapeHTML($_)'")
endfunction
@h1mesuke
h1mesuke / casts.cpp
Created July 28, 2010 23:34
C++ - Sample usages of xxx_cast()
#include <iostream>
using namespace std;
class Base {
virtual void f() {};
};
class Derived: public Base {
};
@h1mesuke
h1mesuke / typeid.cpp
Created July 27, 2010 23:20
C++ - Sample usages of typeid()
#include <iostream>
#include <typeinfo>
using namespace std;
class Base {
virtual void f() {};
};
class Derived1: public Base {
@h1mesuke
h1mesuke / const2.c
Created July 27, 2010 14:26
C - ポインタ変数に対するconst宣言2
#include <stdio.h>
int main(int argc, const char *argv[])
{
const char *p[] = { "foo", "bar", "baz" };
char * const q[] = { "foo", "bar", "baz" };
const char * const r[] = { "foo", "bar", "baz" };
/**** const type *var ****/
@h1mesuke
h1mesuke / const.c
Created July 27, 2010 13:39
C - ポインタ変数に対するconst宣言
#include <stdio.h>
int main(int argc, const char *argv[])
{
int i = 10;
int j = 20;
const int *p = &i;
int * const q = &i;
const int * const r = &i;
@h1mesuke
h1mesuke / multi_inherit_v.cpp
Created July 26, 2010 03:01
C++ - 多重継承時のコンストラクタ/デストラクタの呼び出し順序2
#include <iostream>
using namespace std;
class BaseV
{
public:
BaseV() { cout << "constructor of BaseV\n"; }
~BaseV() { cout << "destructor of BaseV\n"; }
};