Store and Restore Sessions in VIM

Below commands once added in vimrc creates a session with F2 and restore using F3:

map <F2> :mksession! ~/vim_session <cr> " Quick write session with F2
map <F3> :source ~/vim_session <cr> " And load session with F3

You can make any number of sessions using “mksession” command and restore using “source” command from vim editor also.

Git send email

My git send-email config:

git config sendemail.smtpuser 
git config sendemail.smtpserver
git config sendemail.smtpencryption tls
git config sendemail.smtpserverport 587
git config sendemail.suppresscc self
git send-email --to <to_list> --in-reply-to="<message_id_of_message1>" --thread *.patch

This will generate patch in below way:
– Message 1
.           – Patch 1
.                       – Patch 2

This is how I prepared cover page followed by two patches:

git format-patch -2 --subject-prefix="PATCH v2" --cover-letter --thread=shallow
  • Here –cover-later would create a cover page. We need to modify subject and content.
  • The –thread=shallow flag specifies that all patches will be In-Reply-To your cover letter. Hence all patches would be in reply to cover page by default.
  • –subject-prefix=”PATCH v2″ would use given prefix in patch file.

This is how I sent this patches:

git send-email –to <to_id> –cc <cc_id> <patches>

The patch follows below sequence

  • Cover Page
    • Patch 1
    • Patch 2

example patch

Git useful commands

  • Git reset hard remote branch to specific commit
    # git reset --hard <commit-id>
    # git push -f origin <branch_name>
  • Add prefix in patch subject
    # git format-patch --subject-prefix=PREFIX][PATCH
      This will generate a patch with subject: [PREFIX] [PATCH]
  • Get list of new added files between two commits
    # git diff --name-only --diff-filter=A <old-commit-id> <new-commit-id>
  • Get list of modified files between two commits
    # git diff --name-only --diff-filter=M <old-commit-id> <new-commit-id>

Linux Useful Commands

  • List files recursively with path
    find . -name \* -print

    List txt files recursively with path

    find . -name \*.txt -print
  • Remove trailing whitespace of all files recursively
    find <dir> -type f -exec sed -i 's/ *$//' '{}' ';'


How to Change Linux Kernel dmesg buffer size

Printk is implemented by using a ring buffer in the kernel with a size of __LOG_BUF_LEN bytes where __LOG_BUF_LEN equals (1 << CONFIG_LOG_BUF_SHIFT).

dmesg buffer size can be changed using “CONFIG_LOG_BUF_SHIFT” Kconfig.

As per kernel source (4.1.0), default value of this config is 17 (i.e. 1 << 17 = 128KB). The range for this config is 12 to 21.

Addign  below line in defconfig sets

Note: If invalid value (out of range value) is set, default value is taken.

CONFIG_LOG_BUF_SHIFT can be changed from menuconfig or from defconfig as below:


My Favorite vimrc

" An example for a gvimrc file.
" The commands in this are executed when the GUI is started.
" Maintainer:	Bram Moolenaar <>
" Last change:	2001 Sep 02
" To use it, copy it to
"     for Unix and OS/2:  ~/.gvimrc
"	      for Amiga:  s:.gvimrc
"  for MS-DOS and Win32:  $VIM\_gvimrc
"	    for OpenVMS:  sys$login:.gvimrc

" Make external commands work through a pipe instead of a pseudo-tty
"set noguipty

" set the X11 font to use
" set guifont=-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1

set ch=2		" Make command line two lines high

set mousehide		" Hide the mouse when typing text

" Make shift-insert work like in Xterm

" Only do this for Vim version 5.0 and later.
if version >= 500

set guioptions+=a  
set cpoptions-=W

  " I like highlighting strings inside C comments
  let c_comment_strings=1

  " Switch on syntax highlighting if it wasn't on yet.
  if !exists("syntax_on")
    syntax on
map f gu
map F gU

  " Switch on search pattern highlighting.
set hlsearch "highlight previous patter
set ai  "For auto indenting"
set sel=inclusive
set slm=key
set cb=autoselect "clipboard
set km=startsel
set ul=100
set hi=100
set mps=(:),{:},[:],
set sm
set bs=2
set incsearch
set ru

" Hide the mouse pointer while typing
set mousehide

" Set nice colors
" background for normal text is light grey
" Text below the last line is darker grey
" Cursor is green
" Constants are not underlined but have a slightly lighter background
" highlight MatchParen
highlight Normal guibg=White
highlight Cursor guibg=Black guifg=NONE
highlight NonText guibg=White
highlight Constant gui=NONE guibg=grey95
highlight Special gui=NONE guibg=grey95
highlight ErrorMsg guibg=White guifg=Red
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
"set guifontset=-b&h-lucidatypewriter-small-r-normal-*-*-100-*-*-s-*-iso10646-1
"set number
set ruler
"set ts=8
"set sw=2
"set tw=150
syntax on
"syntax match <> /\<\l\+\>/
"syntax match () /\(\l\+\)/
"syntax match {} /\{\l\+\}/
let g:plaintex_delimiters = 1
imap \vo  "=strftime("VST%m%d%y :")Pa 
imap \vc  "=strftime("ACTION : c : VST%m%d%y :")Pa 
imap \c  "set ic"
imap \e  "=strftime("// End of")Pa 

runtime macros/matchit.vim

filetype plugin on
set omnifunc=syntaxcomplete#Complete

vmap  "+yy
map  "+gP

"Show Macro REG => "p e.g. "ap .

set tabpagemax=100
set showcmd
set ic
set colorcolumn=80

map <F2> :mksession! ~/vim_session <cr> " Quick write session with F2 
map <F3> :source ~/vim_session <cr> " And load session with F3