This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1a) Struct declaration and instantiation w/o typedef | |
struct veg_t{ | |
int cost; | |
char c; | |
}; | |
struct veg_t potato; | |
// 1b) or its equivalent with declaration and instantiation combined… | |
struct veg_t{ | |
int cost; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! MapKey( rhs, mode ) | |
" Description: Get LHS of a mapping. Inverse of maparg(). | |
" Note that hasmapto() returns a binary result while MapKey() returns the value of the LHS. | |
" Pass in a key sequence and the first letter of a vim mode. | |
" Returns key mapping mapped to it in that mode, else '' if none. | |
" Eg: | |
" :nnoremap <Tab> :bn<CR> | |
" :call Mapkey(':bn<CR>', 'n') | |
" returns <Tab> | |
" TODO: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! ReTab( tabsize ) | |
" Description: Change indentation when tab size is changed | |
" Primarily used to convert an indentation of eg. 4 to 2 or vice-versa | |
if &expandtab | |
let l:tabstop_old = &tabstop | |
let l:softtabstop_old = &softtabstop | |
let l:shiftwidth_old = &shiftwidth | |
let &tabstop = &softtabstop | |
set noexpandtab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Motion for "next/last object". | |
" For example, 'din(' will go to the Next '()' pair and delete its contents. | |
" and 'dip(' will go to the Previous '()' pair and delete its contents. | |
onoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr> | |
xnoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr> | |
onoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr> | |
xnoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr> | |
onoremap ap :<c-u>call <SID>NextTextObject('a', 'F')<cr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! FoldAllBut( foldminlines ) | |
" Description: Function to open folds that have less than the specified number of lines | |
" We assume that the folds are initially closed | |
" If a fold exists and is closed and has lesser number of lines than specified, open it and all nested folds | |
" Note: This does not work on nested folds | |
folddoclosed | |
\ if (( foldclosed(".") >= 0 ) && ( foldclosedend(".") - foldclosed(".") + 1 < a:foldminlines )) | |
\ exe 'normal! zO' | |
\ endif | |
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This uses positive look-ahead to check if there's a string ahead to substitute commas present outside quoted strings. | |
s/\v,(([^"]*"[^"]*")*[^"]*$)@=/|/g | |
Explanation: | |
* "[^"]*" | |
Match a double-quoted string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Statusline modifications, added Fugitive Status Line & Syntastic Error Message | |
let g:last_mode = '' | |
function! Mode() | |
let l:mode = mode() | |
if l:mode !=# g:last_mode | |
let g:last_mode = l:mode | |
hi User2 guifg=#005f00 guibg=#dfff00 gui=BOLD ctermfg=22 ctermbg=190 cterm=BOLD | |
hi User3 guifg=#FFFFFF guibg=#414243 ctermfg=255 ctermbg=241 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nnoremap <silent> <F8> :let notabs=!notabs<Bar>:if notabs<Bar>:tabo<Bar>:else<Bar>:tab ball<Bar>:tabn<Bar>:endif<CR> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! VaryTabs() | |
" Description: Make <Tab> put tabs at start of line and spaces elsewhere | |
if &expandtab | |
return "\<Tab>" | |
else | |
let nonwhite = matchend(getline('.'),'\S') | |
if nonwhite < 0 || col('.') <= nonwhite | |
return "\<Tab>" | |
else | |
let pos = virtcol('.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! FoldText() | |
" Description: Folding configuration | |
let nucolwidth = &fdc + &number*&numberwidth | |
let winwidth = winwidth(0) - nucolwidth - 3 | |
let foldlinecount = foldclosedend(v:foldstart) - foldclosed(v:foldstart) + 1 | |
let dashtext = strpart(string(v:folddashes),1,len(string(v:folddashes))-2) | |
let foldinfo = "+" . dashtext . " Fold: " . string(v:foldlevel) . ", " . string(foldlinecount) . " lines " | |
let firstline = strpart(getline(v:foldstart), 0 , winwidth - len(foldinfo)) | |
let fillcharcount = winwidth - len(firstline) - len(foldinfo) | |
return firstline . repeat(" ",fillcharcount) . foldinfo |
OlderNewer