Skip to content

Instantly share code, notes, and snippets.

@javier-lopez
Created September 24, 2016 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javier-lopez/880a02d9669b71d772d66eebdf3151e4 to your computer and use it in GitHub Desktop.
Save javier-lopez/880a02d9669b71d772d66eebdf3151e4 to your computer and use it in GitHub Desktop.
24 de Septiembre
@javier-lopez
Copy link
Author

JRebel, http://zeroturnaround.com/software/jrebel/

Actualizacion de aplicaciones Java en línea

@humus
Copy link

humus commented Sep 24, 2016

Ver los mapeos específicos al buffer actual

:map <buffer>

@humus
Copy link

humus commented Sep 24, 2016

Plugin de autocomplete para Java (requiere Java 8 y soporte de python)

https://github.com/artur-shaik/vim-javacomplete2

@humus
Copy link

humus commented Sep 24, 2016

Funciones para trabajar con java en la consola, proyectos Maven 3

https://raw.githubusercontent.com/humus/bash_functions/master/java_functions.sh

Código vimscript de ejemplo para usar tmux y las funciones de desarrollo de java

let g:tmux= 'C:/git-sdk-64/usr/bin/tmux'

fun! Fqcn() "{{{
 let s:lnum = search('\v^package[^;]+;\s*$', 'n')
  let s:strline = getline(s:lnum)
  let s:packagename=matchstr(s:strline, '\v^package\s+\zs[^;]+\ze;')
  return s:packagename . '.' . expand('%:t:r')
endfunction "}}}

fun! Compile() "{{{
  execute 'silent! !' . g:tmux . ' send-keys "cpjar_javac ' . expand('%:t:r')  . '" c-m'
  redraw!
endfunction "}}}

fun! CompileTest() "{{{
  let l:command = 'cpjar_javac ' . expand('%:t:r')

  if expand('%:t:r') =~ '\v.*Test$'
      let l:command .= ' && cpjar_junit ' . Fqcn()
  endif

  execute 'silent! !' . g:tmux . ' send-keys " ' . l:command . '" c-m'
endfunction "}}}

fun! Execute() "{{{
  execute 'silent! !' . g:tmux . ' send-keys "cpjar_javax ' . Fqcn()  . '" c-m'
  redraw!
endfunction "}}}

fun! Execute_test() "{{{
  execute 'silent! !' . g:tmux . ' send-keys "cpjar_junit ' . Fqcn() . '" c-m'
  redraw!
endfunction "}}}

fun! Get_cache_feature_file(file) "{{{
  let f = findfile('pom.xml', fnamemodify(a:file, ':p:h').';')
  let f = Normalize_my_path(f)
  let cache_dir = Cache_dir_for_path(f)
  let cache_file = cache_dir . '/' . fnamemodify(a:file, ':t') . '.txt'
  if filereadable(cache_file)
    call View_temporal_buffer(cache_file)
  endif
endfunction "}}}

fun! View_temporal_buffer(file) "{{{
  keepalt botright new
  setlocal wrap buftype=nowrite bufhidden=wipe nobuflisted noswapfile
  execute 'silent f ' . fnamemodify(a:file, ':t:r')
  nnoremap <buffer> q :bw!<cr>
  execute 'silent! read ' . a:file
endfunction "}}}

fun! Cache_dir_for_path(path)  "{{{
  let path = substitute(a:path, '/', '_', 'g')
  let path = g:cache_projects_dir . '/' . path
  return path
endfunction "}}}

fun! Normalize_my_path(path) "{{{
  let l:f = a:path
  let l:f = fnamemodify(l:f, ':p:h')
  let l:f = substitute(l:f, '\\', '/', 'g')
  let l:f = substitute(l:f, '\v\C([A-Z]):', '/\1', '')
  return l:f
endfunction "}}}

noremap! <buffer> ,,c <C-r>=Fqcn()<cr>
noremap <buffer> ,,c :call Compile()<cr>
noremap <buffer> ,,x :call Execute()<cr>
noremap <buffer> ,,t :call Execute_test()<cr>


augroup save_compile
  au!
  au BufWritePost *.java call CompileTest()
augroup END


@humus
Copy link

humus commented Sep 24, 2016

g9 y g0 para cambiar el tamaño de la fuente

fun! Fontsize_up() "{{{
  let font = &guifont
  let beforesize = font[0:matchend(font, '\v\.*\ze[^\d][[:digit:]]+')]
  let index = match(font, '\v[^:]\zs:\w+$') - len(font)
  let aftersize = font[index : ]
  let size = str2nr(matchstr(font, '\v.*[^[:digit:]]\zs[[:digit:]]+\ze:.*'))
  let size += 1
  let new_font = beforesize . size . aftersize
  execute 'set guifont=' . new_font
endfunction "}}}

fun! Fontsize_down() "{{{
  let font = &guifont
  let beforesize = font[0:matchend(font, '\v\.*\ze[^\d][[:digit:]]+')]
  let index = match(font, '\v[^:]\zs:\w+$') - len(font)
  let aftersize = font[index : ]
  let size = str2nr(matchstr(font, '\v.*[^[:digit:]]\zs[[:digit:]]+\ze:.*'))
  let size -= 1
  let new_font = beforesize . size . aftersize
  execute 'set guifont=' . new_font
endfunction "}}}

fun! Before_size() "{{{
  echo matchstr(&guifont, '\v^.+[^[:digit:]]\ze\d+:')
endfunction "}}}

fun! After_size() "{{{
  echo matchstr(&guifont, '\v[^[:digit:]]\d+\zs:\w+$')
endfunction "}}}


nnoremap <silent> g0 :call Fontsize_up()<cr>
nnoremap <silent> g9 :call Fontsize_down()<cr>
" vim: sw=2 ts=2 sts=2 et

@humus
Copy link

humus commented Sep 24, 2016

Revisar si tienes vim --remote-silent

echo has('clientserver')

@humus
Copy link

humus commented Sep 24, 2016

Utilizando features avanzados de vanilla vim

http://vimcasts.org/episodes/vimgolf-prime-numbers/

@humus
Copy link

humus commented Sep 24, 2016

Los macros son registros y se pueden editar en texto plano

Para pegar el macro w en el buffer actual:

"wp

Pasar texto al macro w (primero seleccionar en modo visual)

"wy

@humus
Copy link

humus commented Sep 24, 2016

modeline puedes verlo en :h modeline

" vim: sw=2 ts=2 sts=2 et

@humus
Copy link

humus commented Sep 24, 2016

Transmite en directo videos de programación:
https://www.twitch.tv/gary_bernhardt

@humus
Copy link

humus commented Sep 24, 2016

Undo persistente

set undodir=C:\vim2\tmp\undo
set noswf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment