Last active
May 16, 2018 15:47
-
-
Save NSLog0/c6135a7d56ee069467f8b0b8caf1c945 to your computer and use it in GitHub Desktop.
Vim tutorials
This file contains hidden or 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
var commend_helper = { | |
':w': 'บันทึกไฟล์', | |
':wq': 'บันทึกและออก', | |
':q': 'ออกแบบปกติ', | |
':q!': 'ออกแบบไม่บันทึก', | |
Esc: 'ออกจากโหมด insert, virtual, normal', | |
':': 'เรียกใช้คำสั่ง Plugin หรือคำสั่ง Buildin' | |
}; |
This file contains hidden or 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
var editing_help = { | |
u: 'undo (ctrl-z)', | |
'.': 'ทำคำสั่งล่าสุดซ้ำ (จุด)', | |
yy: 'คัดลอกทั่งบรรทัด', | |
p: 'วาง', | |
dd: 'ลบทั่งบรรทัด จริงๆ มันคือการทำ cut text', | |
x: 'ลบตัวที่ cursor ชี้อยู่', | |
>: 'เลือน Indent เข้า', | |
<: 'เลือน Indent ออก', | |
}; |
This file contains hidden or 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
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \ | |
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |
This file contains hidden or 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
var editing = { | |
s: 'ลบอักษรที่ cursor ชี้อยู่ 1 ตัวและเข้า insert mode', | |
cc: 'ลบทั่งบรรทัดออกแล้วเข้า insert mode', | |
i: 'เข้า insert mode', | |
J: 'รวมบรรทัดล่างกับบนเข้าด้วยกัน หรือเรียกว่า join ไม่เข้า insert mode แต่ถือว่าอยู่ในการ edit ไฟล์', | |
a: 'เข้า insert mode และขยับ cursor ไป 1 ช่อง' | |
}; |
This file contains hidden or 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
sudo apt-get -y install vim |
This file contains hidden or 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
call plug#begin() | |
Plug 'mattn/emmet-vim' | |
Plug 'pangloss/vim-javascript' | |
Plug 'vim-ruby/vim-ruby' | |
Plug 'mxw/vim-jsx' | |
Plug 'isruslan/vim-es6' | |
Plug 'cakebaker/scss-syntax.vim' | |
Plug 'hail2u/vim-css3-syntax' | |
Plug 'altercation/vim-colors-solarized' | |
Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] } | |
Plug 'airblade/vim-gitgutter' | |
Plug 'jelera/vim-javascript-syntax' | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' | |
Plug 'nathanaelkane/vim-indent-guides' | |
Plug 'tpope/vim-commentary' | |
call plug#end() |
This file contains hidden or 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
var cursor = { | |
h: 'เลือนซ้าย', | |
j: 'เลือนลง', | |
k: 'เลือนขึ้น', | |
l: 'เลือนขวา (อักษรแอลเล็ก)', | |
w: 'เลือนเป็นคำหรือประโยค เริ่มจากอักษรตัวแรกของคำ', | |
e: 'เลือนเป็นคำหรือประโยค เริ่มจากอักษรตัวหลังของคำ', | |
b: 'เลือนกลับที่ละคำหรือประโยค', | |
0: 'เลือนไปยังจุดเริ่มต้นบรรทัด', | |
$: 'เลือนไปยังท้ายสุดของบรรทัด', | |
G: 'เลือนไปท้ายไฟล์', | |
gg: 'เลือนไปบนสุดของไฟล์', | |
o: 'เพิ่มบรรทัดด้านล่างและเข้ามโหมด insert', | |
O: 'เพิ่มบรรทัดขึ้นข้างบนและเข้ามโหมด insert' | |
}; |
This file contains hidden or 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
1. $ > vim path/file or filename | |
2. $ > vim . |
This file contains hidden or 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
set encoding=utf-8 " file encode | |
" The advantage of having the status line displayed always is, you can see the current mode, file name, file status, ruler, etc. | |
set laststatus=2 | |
" fix backspace notworking | |
set backspace=indent,eol,start | |
" display status line/colmun number at buttom | |
set ruler | |
" display line number | |
set number | |
" open highlight syntax | |
syntax on | |
" set term=builtin_ansi | |
" set term=xterm-256color | |
" colorscheme basic-dark | |
" colorscheme mayansmoke | |
" set background=dark | |
" set theme | |
colorscheme petrel | |
This file contains hidden or 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
let s:comment_map = { | |
\ "c": '\/\/', | |
\ "cpp": '\/\/', | |
\ "go": '\/\/', | |
\ "java": '\/\/', | |
\ "javascript": '\/\/', | |
\ "lua": '--', | |
\ "scala": '\/\/', | |
\ "php": '\/\/', | |
\ "python": '#', | |
\ "ruby": '#', | |
\ "rust": '\/\/', | |
\ "sh": '#', | |
\ "desktop": '#', | |
\ "fstab": '#', | |
\ "conf": '#', | |
\ "profile": '#', | |
\ "bashrc": '#', | |
\ "bash_profile": '#', | |
\ "mail": '>', | |
\ "eml": '>', | |
\ "bat": 'REM', | |
\ "ahk": ';', | |
\ "vim": '"', | |
\ "tex": '%', | |
\ } | |
function! ToggleComment() | |
if has_key(s:comment_map, &filetype) | |
let comment_leader = s:comment_map[&filetype] | |
if getline('.') =~ "^\\s*" . comment_leader . " " | |
" Uncomment the line | |
execute "silent s/^\\(\\s*\\)" . comment_leader . " /\\1/" | |
else | |
if getline('.') =~ "^\\s*" . comment_leader | |
" Uncomment the line | |
execute "silent s/^\\(\\s*\\)" . comment_leader . "/\\1/" | |
else | |
" Comment the line | |
execute "silent s/^\\(\\s*\\)/\\1" . comment_leader . " /" | |
end | |
end | |
else | |
echo "No comment leader found for filetype" | |
end | |
endfunction | |
nnoremap <leader><Space> :call ToggleComment()<CR> | |
vnoremap <leader><Space> :call ToggleComment()<CR> |
This file contains hidden or 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
" coding indent setting | |
set tabstop=2 " change tab width | |
set shiftwidth=2 " affects what happens when you press >>, << or = | |
set softtabstop=2 " tell backspace gose back step or tab width | |
set expandtab " convert tab to space |
This file contains hidden or 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
" setup key with recursive | |
map <leader>w :w<CR> | |
map <leader>q :q<CR> | |
map j gg | |
map Q j | |
" setup key with non-recursive | |
noremap W j | |
" setup key for call plugin function | |
map <C-n> :NERDTreeToggle<CR> |
This file contains hidden or 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
" plugin setting | |
let g:airline_theme='luna' | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline#extensions#tabline#left_sep = ' ' | |
let g:airline#extensions#tabline#left_alt_sep = '|' | |
let g:airline_powerline_fonts = 1 |
This file contains hidden or 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
visual_key: { | |
y: 'คัดลอก', | |
d: 'ลบทั่งบรรทัดออก มันคือการทำ cut text', | |
>: 'เลือน Indent เข้า', | |
<: 'เลือน Indent ออก', | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment