Advertisement
Guest User

vim termux fixes

a guest
Oct 10th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 1.52 KB | None | 0 0
  1. " encoding fix, for russian, hopefuly universal
  2. set enc=utf-8
  3. set fileencoding=utf-8
  4. set fileencodings=ucs-bom,utf8,prc
  5. set guifont=Monaco:h11
  6. set guifontwide=NSimsun:h12
  7.  
  8. " indent fix, tab shown as 1 space, pc-friendly
  9. set nocindent
  10. set nosmartindent
  11. set nosmarttab
  12. set noexpandtab
  13. set shiftwidth=1
  14. set softtabstop=1
  15. set tabstop=1
  16. set ignorecase
  17. filetype indent off
  18.  
  19. " fix for navigation like in all other editors
  20. nnoremap <expr> <Up> (v:count == 0 ? 'gk' : 'k')
  21. nnoremap <expr> <Down> (v:count == 0 ? 'gj' : 'j')
  22. inoremap <expr> <silent> <Up>   pumvisible() ? "\<Up>" : "\<C-o>gk"
  23. inoremap <expr> <silent> <Down> pumvisible() ? "\<Down>" : "\<C-o>gj"
  24. set whichwrap+=<,>,h,l,[,],b,s
  25.  
  26. " copy-paste fix. also do both:
  27. " pkg install termux-api
  28. " google play download 'termux api'
  29. nnoremap <C-c> :'<,'>w !termux-clipboard-set<CR>
  30. nnoremap <C-v> :r !termux-clipboard-get<CR>
  31.  
  32. " text and code folding, no special symbols
  33. " 1 new line = same foldlevel
  34. " 2 new lines = increase foldlevel
  35. " 3 new lines = decrease foldlevel
  36. let b:ind=0
  37. let b:progress=0
  38. let b:newlines=0
  39. set foldmethod=expr
  40. set foldexpr=VimFoldLevel(v:lnum)
  41. function! VimFoldLevel(line)
  42.     if(b:progress<=a:line)
  43.         let b:progress=a:line else return endif
  44.     if getline(a:line) =~ '^[ \t]*$'
  45.         let b:newlines=b:newlines+1
  46.         if b:newlines==2
  47.             return b:ind+1
  48.         endif
  49.         if b:newlines==3
  50.             let b:ind=max([b:ind-1,0])
  51.         endif
  52.         return b:ind
  53.     else   
  54.         if b:newlines==2
  55.             let b:ind=b:ind+1
  56.         endif
  57.         let b:newlines=0
  58.         return b:ind+1
  59.     endif
  60. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement