1
0
mirror of https://github.com/amix/vimrc synced 2025-02-28 14:12:51 +08:00

Mac -> master (#1)

* se elimina la instalación básica
* traducción y modificación de README.md
* traducción y modificación de basic.vim
This commit is contained in:
Facundo Laffont 2016-09-03 20:31:57 -03:00 committed by GitHub
parent 183ca1cfc5
commit 690a8e40ce
4 changed files with 139 additions and 408 deletions

278
README.md
View File

@ -1,69 +1,18 @@
# The Ultimate vimrc
# Fork de amix/vimrc optimizado para MacBook Pro 15"
Over the last 8 years I have used and tweaked Vim. This is my Ultimate vimrc.
## Instalación
There are two versions:
git clone https://github.com/facundolaffont/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/instalación.sh
* **Basic**: If you want something small just copy [basic.vim](https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim) into your ~/.vimrc and you will have a great basic setup
* **Awesome**: This includes a ton of useful plugins, color schemes and configurations
Es recomendable usar las [fuentes tipográficas Source Code Pro](https://github.com/adobe-fonts/source-code-pro). Son gratis y están alojadas en GitHub
I would of course recommend using the awesome version.c
## How to install the Awesome version?
The awesome version includes a lot of great plugins, configurations and color schemes that make Vim a lot better. To install it simply do following:
git clone https://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_awesome_vimrc.sh
I also recommend using [Source Code Pro font from Adobe](http://store1.adobe.com/cfusion/store/html/index.cfm?event=displayFontPackage&code=1960) (it's free and awesome font for writing and programming). The Awesome vimrc is already setup to try to use it
## How to install the Basic version?
The basic version is basically just one file and no plugins. You can check out [basic.vim](https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim).
This is useful to install on remote servers where you don't need many plugins and you don't do many edits.
git clone git://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_basic_vimrc.sh
## How to install on Windows?
Use [msysgit](http://msysgit.github.com/) to checkout the repository and run the installation instructions above. No special instructions needed ;-)
## How to install on Linux
If you have vim aliased as `vi` instead of `vim`, make sure to either alias it: `alias vi=vim`. Otherwise, `apt-get install vim`
## How to update to latest version?
Simply just do a git rebase!
## Cómo actualizar a la última versión
cd ~/.vim_runtime
git pull --rebase
## Some screenshots
Colors when editing a Python file:
![Screenshot 1](http://files1.wedoist.com/e952fdb343b1e617b90d256e474d0370/as/screenshot_1.png)
Opening recently opened files [mru.vim](https://github.com/vim-scripts/mru.vim):
![Screenshot 2](http://files1.wedoist.com/1967b0e48af40e513d1a464e08196990/as/screenshot_2.png)
[NERD Tree](https://github.com/scrooloose/nerdtree) plugin in a terminal window:
![Screenshot 3](http://files1.wedoist.com/b1509d7ed9e9f357e8d04797f9fad67b/as/screenshot3.png)
This vimrc even works on Windows!
![Screenshot 4](http://files1.wedoist.com/4e85163d97b81422240c822c82022f2f/as/screenshot_4.png)
Distraction free mode using [goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2):
![Screenshot 5](https://d2dq6e731uoz0t.cloudfront.net/a5182977c3d6c2a6cd3f9e97398ca8ca/as/zen_mode.jpg)
## Included Plugins
I recommend reading the docs of these plugins to understand them better. Each of them provide a much better Vim experience!
## Plugins incluídos
* [pathogen.vim](https://github.com/tpope/vim-pathogen): Manages the runtime path of the plugins
* [snipMate.vim](https://github.com/garbas/vim-snipmate): snipMate.vim aims to be a concise vim script that implements some of TextMate's snippets features in Vim
@ -86,16 +35,16 @@ Remove all clutter and focus only on the essential. Similar to iA Writer or Writ
* [lightline.vim](https://github.com/itchyny/lightline.vim): A light and configurable statusline/tabline for Vim
## Included color schemes
## Esquemas de colores incluídos
* [peaksea](https://github.com/vim-scripts/peaksea): My favorite!
* [peaksea](https://github.com/vim-scripts/peaksea)
* [vim-colors-solarized](https://github.com/altercation/vim-colors-solarized)
* [vim-irblack](https://github.com/wgibbs/vim-irblack)
* [mayansmoke](https://github.com/vim-scripts/mayansmoke)
* [vim-pyte](https://github.com/therubymug/vim-pyte)
## Included modes
## Modos incluídos
* [vim-coffee-script](https://github.com/kchmck/vim-coffee-script)
* [vim-less](https://github.com/groenewege/vim-less)
@ -104,211 +53,14 @@ Remove all clutter and focus only on the essential. Similar to iA Writer or Writ
* [nginx.vim](https://github.com/vim-scripts/nginx.vim): Highlights configuration files for nginx
* [vim-go](https://github.com/fatih/vim-go)
## How to include your own stuff?
After you have installed the setup you can create **~/.vim_runtime/my_configs.vim** to fill in any configurations that are important for you. For instance, my **my_configs.vim** looks like this:
~/.vim_runtime (master)> cat my_configs.vim
map <leader>ct :cd ~/Desktop/Todoist/todoist<cr>
map <leader>cw :cd ~/Desktop/Wedoist/wedoist<cr>
You can also install your own plugins, for instance, via pathogen we can install [vim-rails](https://github.com/tpope/vim-rails):
Se pueden instalar plugins personalizados, por ejemplo, via pathogen:
cd ~/.vim_runtime
git clone git://github.com/tpope/vim-rails.git sources_non_forked/vim-rails
Now you have vim-rails installed ;-)
Con estos dos comandos, ya se tendría instalado el plugin vim-rails
## Key Mappings
### Plugin related mappings
Open [bufexplorer](https://github.com/vim-scripts/bufexplorer.zip) and see and manage the current buffers (`<leader>o`):
map <leader>o :BufExplorer<cr>
Open [MRU.vim](https://github.com/vim-scripts/mru.vim) and see the recently open files (`<leader>f`):
map <leader>f :MRU<CR>
Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin (`<leader>j` or `<ctrl>f`):
let g:ctrlp_map = '<c-f>'
Managing the [NERD Tree](https://github.com/scrooloose/nerdtree) plugin:
map <leader>nn :NERDTreeToggle<cr>
map <leader>nb :NERDTreeFromBookmark
map <leader>nf :NERDTreeFind<cr>
[goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2) lets you only focus on one thing at a time. It removes all the distractions and centers the content. It has a special look when editing Markdown, reStructuredText and textfiles. It only has one mapping. (`<leader>z`)
map <leader>z :Goyo<cr>
### Normal mode mappings
Fast saving of a buffer (`<leader>w`):
nmap <leader>w :w!<cr>
Map `<Space>` to `/` (search) and `<Ctrl>+<Space>` to `?` (backwards search):
map <space> /
map <c-space> ?
map <silent> <leader><cr> :noh<cr>
Disable highlight when `<leader><cr>` is pressed:
map <silent> <leader><cr> :noh<cr>
Smart way to move between windows (`<ctrl>j` etc.):
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
Closing of current buffer(s) (`<leader>bd` and (`<leader>ba`)):
" Close current buffer
map <leader>bd :Bclose<cr>
" Close all buffers
map <leader>ba :1,1000 bd!<cr>
Useful mappings for managing tabs:
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
Switch CWD to the directory of the open buffer:
map <leader>cd :cd %:p:h<cr>:pwd<cr>
Open vimgrep and put the cursor in the right position:
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
Vimgreps in the current file:
map <leader><space> :vimgrep // <C-R>%<C-A><right><right><right><right><right><right><right><right><right>
Remove the Windows ^M - when the encodings gets messed up:
noremap <leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
Quickly open a buffer for scripbble:
map <leader>q :e ~/buffer<cr>
Toggle paste mode on and off:
map <leader>pp :setlocal paste!<cr>
### Insert mode mappings
Quickly insert parenthesis/brackets/etc.:
inoremap $1 ()<esc>i
inoremap $2 []<esc>i
inoremap $3 {}<esc>i
inoremap $4 {<esc>o}<esc>O
inoremap $q ''<esc>i
inoremap $e ""<esc>i
inoremap $t <><esc>i
Insert the current date and time (useful for timestamps):
iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
### Visual mode mappings
Visual mode pressing `*` or `#` searches for the current selection:
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
When you press gv you vimgrep after the selected text:
vnoremap <silent> gv :call VisualSelection('gv')<CR>
When you press `<leader>r` you can search and replace the selected text:
vnoremap <silent> <leader>r :call VisualSelection('replace')<CR>
Surround the visual selection in parenthesis/brackets/etc.:
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
vnoremap $q <esc>`>a'<esc>`<i'<esc>
vnoremap $e <esc>`>a"<esc>`<i"<esc>
### Command line mappings
$q is super useful when browsing on the command line. It deletes everything until the last slash:
cno $q <C-\>eDeleteTillSlash()<cr>
Bash like keys for the command line:
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
Write the file as sudo (only on Unix). Super useful when you open a file and you don't have permissions to save your changes. [Vim tip](http://vim.wikia.com/wiki/Su-write):
:W
### Spell checking
Pressing `<leader>ss` will toggle and untoggle spell checking
map <leader>ss :setlocal spell!<cr>
Shortcuts using `<leader>` instead of special chars
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
### Cope
Do :help cope if you are unsure what cope is. It's super useful!
When you search with vimgrep, display your results in cope by doing:
`<leader>cc`
To go to the next search result do:
`<leader>n`
To go to the previous search results do:
`<leader>p`
Vimscript mappings:
map <leader>cc :botright cope<cr>
map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
map <leader>n :cn<cr>
map <leader>p :cp<cr>
## How to uninstall
Do following:
* Remove `~/.vim_runtime`
* Remove any lines that refernce `.vim_runtime` in your `~/.vimrc`
## Cómo desinstalar
* Borrar `~/.vim_runtime`
* Borrar cualquier línea que haga referencia a `.vim_runtime` en tu archivo `~/.vimrc`

View File

@ -12,4 +12,4 @@ source ~/.vim_runtime/my_configs.vim
catch
endtry' > ~/.vimrc
echo "Installed the Ultimate Vim configuration successfully! Enjoy :-)"
echo "Instalación finalizada!"

View File

@ -1,3 +0,0 @@
cd ~/.vim_runtime
cat ~/.vim_runtime/vimrcs/basic.vim > ~/.vimrc
echo "Installed the Basic Vim configuration successfully! Enjoy :-)"

View File

@ -1,28 +1,9 @@
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer:
" Amir Salihefendic
" http://amix.dk - amix@amix.dk
" Mantenimiento:
" Facundo Laffont
" facundolaffont@gmail.com
"
" Version:
" 5.0 - 29/05/12 15:43:36
"
" Blog_post:
" http://amix.dk/blog/post/19691#The-ultimate-Vim-configuration-on-Github
"
" Awesome_version:
" Get this config, nice color schemes and lots of plugins!
"
" Install the awesome version from:
"
" https://github.com/amix/vimrc
"
" Syntax_highlighted:
" http://amix.dk/vim/vimrc.html
"
" Raw_version:
" http://amix.dk/vim/vimrc.txt
"
" Sections:
" Secciones:
" -> General
" -> VIM user interface
" -> Colors and Fonts
@ -41,131 +22,121 @@
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
" => general
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
" Cuántas líneas de historia debe recordar Vim
set history=500
" Enable filetype plugins
" Habilita la carga de archivos de plugins/indent según el tipo de archivo que se está utilizando
filetype plugin on
filetype indent on
" Set to auto read when a file is changed from the outside
" Cuando el archivo es modificado desde afuera de Vim, se vuelve a cargar
set autoread
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
" Se va a utilizar el mapleader para generar combinaciones de tecla extra
let mapleader = ","
let g:mapleader = ","
" Fast saving
" guardado rápido
nmap <leader>w :w!<cr>
" :W sudo saves the file
" (useful for handling the permission-denied error)
" <?>
" :W sudo saves the file (useful for handling the permission-denied error)
command W w !sudo tee % > /dev/null
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
" => interfaz de usuario de Vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
" Avoid garbled characters in Chinese language windows OS
let $LANG='en'
set langmenu=en
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
" deja un espacio de 5 líneas entre el curso y el borde superior o inferior
set so=5
" Turn on the WiLd menu
" activa el menú Wild
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
if has("win16") || has("win32")
set wildignore+=.git\*,.hg\*,.svn\*
else
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
endif
" ignora los archivos de compilación (útil para git)
set wildignore=*.o,*~,*.pyc,*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
"Always show current position
" siempre muestra la posición del cursor
set ruler
" Height of the command bar
" altura de la línea de comandos
set cmdheight=2
" <?>
" A buffer becomes hidden when it is abandoned
set hid
" Configure backspace so it acts as it should act
" configura backspace, los comandos h y l, y los movimientos con las flechas para que el cursor
" responda como normalmente lo hace fuera de Vim, cuando se está al principio o final de la línea
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Ignore case when searching
" ignora la sensibilidad de las mayúsculas cuando se está buscando
set ignorecase
" When searching try to be smart about cases
" realiza búsquedas inteligentes en cuanto a la sensibilidad de las mayúsculas
set smartcase
" Highlight search results
" resalta los resultados de las búsquedas
set hlsearch
" Makes search act like search in modern browsers
" hace que la búsqueda actúe como en los navegadores web modernos
set incsearch
" Don't redraw while executing macros (good performance config)
" no redibuja cuando se ejecutan macros (buena performance)
set lazyredraw
" For regular expressions turn magic on
" activa magic para las expresiones regulares
set magic
" Show matching brackets when text indicator is over them
" muestra el paréntesis opuesto cuando el cursor está sobre uno
set showmatch
" How many tenths of a second to blink when matching brackets
" cuántas decenas de segundos tarda en parpadear el cursor cuando se indica el paréntesis opuesto
set mat=2
" No annoying sound on errors
" quita el sonido y el flash en los errores
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Add a bit extra margin to the left
" agrega un poco de margen a la izquierda
set foldcolumn=1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
" => colores y fuentes tipográficas
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
" habilita el resaltado según sintaxis
syntax enable
" intenta utilizar el esquema de color desert
try
colorscheme desert
catch
endtry
" si el color de fondo es un color oscuro, Vim utiliza colores que contrasten mejor con ese tipo de
" color de fondo
set background=dark
" Set extra options when running in GUI mode
if has("gui_running")
set guioptions-=T
set guioptions-=e
set t_Co=256
set guitablabel=%M\ %t
endif
" Set utf8 as standard encoding and en_US as the standard language
" establece utf8 como la codificación estándar
set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
" utiliza Unix como tipo de archivo estándar
set ffs=unix,mac,dos
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
" => archivos, back-ups y deshacer
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
@ -173,122 +144,120 @@ set noswapfile
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
" => texto, tabulación e indentación
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
" usa espacios en vez de tabulación
set expandtab
" Be smart when using tabs ;)
" usa las tabulaciones de manera inteligente
set smarttab
" 1 tab == 4 spaces
" 1 tabulación == 4 espacios
set shiftwidth=4
set tabstop=4
" Linebreak on 500 characters
" el quiebre de línea se realiza a los 100 caracteres
set lbr
set tw=500
set tw=100
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines
" establece autoindentación, indentación inteligente y quiebre de líneas
set ai
set si
set wrap
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => relacionado con el modo visual
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" en modo Visual, presionando * o ¿, busca la selección actual
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
vnoremap <silent> ¿ :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs, windows and buffers
" => sobre movimiento, pestañas, ventanas y buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
" mapeos de búsqueda
map <space> /
map <c-space> ?
" <¿>no funciona<?>
map <C-Space> ?
" Disable highlight when <leader><cr> is pressed
" deshabilita el resaltado de las búsquedas
map <silent> <leader><cr> :noh<cr>
" Smart way to move between windows
" movimiento entre ventanas
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Close the current buffer
" cierra el buffer actual
map <leader>bd :Bclose<cr>:tabclose<cr>gT
" Close all the buffers
" cierra todos los buffers
map <leader>ba :bufdo bd<cr>
" navegación entre buffers
map <leader>l :bnext<cr>
map <leader>h :bprevious<cr>
" Useful mappings for managing tabs
" navegación entre pestañas
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
map <leader>t<leader> :tabnext
map <leader>t<leader> :tabnext<cr>
" Let 'tl' toggle between this and the last accessed tab
" 'tl' salta entre la pestaña actual y la última a la que se accedió
let g:lasttab = 1
nmap <Leader>tl :exe "tabn ".g:lasttab<CR>
au TabLeave * let g:lasttab = tabpagenr()
" abre una nueva pestaña con la ruta del buffer actual
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/<cr>
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" <¿?>
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
" Specify the behavior when switching between buffers
" especifica el comportamiento cuando se cambia de buffer
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
" Return to last edit position when opening files (You want this!)
" al abrir un archivo, vuelve al mismo punto donde se dejó cuando se cerró
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
""""""""""""""""""""""""""""""
" => Status line
""""""""""""""""""""""""""""""
" Always show the status line
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => línea de estado
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" siempre muestra la línea de estado
set laststatus=2
" Format the status line
" formateo de la línea de estado
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
" => mapeos para edición
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remap VIM 0 to first non-blank character
" remapea '0' para que posicione el cursor en el primer carácter no blanco
map 0 ^
" Move a line of text using ALT+[jk] or Command+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
" <¿>no funciona correctamente<?>
" mueve una línea de texto hacia arriba o hacia abajo
nmap <D-j> mz:m+<cr>`z
nmap <D-k> mz:m-2<cr>`z
vmap <D-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <D-k> :m'<-2<cr>`>my`<mzgv`yo`z
if has("mac") || has("macunix")
nmap <D-j> <M-j>
nmap <D-k> <M-k>
vmap <D-j> <M-j>
vmap <D-k> <M-k>
endif
" Delete trailing white space on save, useful for Python and CoffeeScript ;)
" borra los espacios sobrantes al final de la línea, cuando se guarda el buffer
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
@ -297,11 +266,12 @@ endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
autocmd BufWrite *.coffee :call DeleteTrailingWS()
" <¿>falta chequear toda esta sección<?>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Ag searching and cope displaying
" requires ag.vim - it's much better than vimgrep/grep
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" When you press gv you Ag after the selected text
vnoremap <silent> gv :call VisualSelection('gv', '')<CR>
@ -329,12 +299,13 @@ map <leader>p :cp<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
" => chequeo de gramática
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pressing ,ss will toggle and untoggle spell checking
" activa o desactiva el chequeo de gramática
map <leader>ss :setlocal spell!<cr>
" Shortcuts using <leader>
" atajos para herramientas de la gramática
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
@ -342,36 +313,46 @@ map <leader>s? z=
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Misc
" => misceláneo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove the Windows ^M - when the encodings gets messed up
" quita los caracteres ^M de windows cuando las codificaciones de texto se mezclan
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" Quickly open a buffer for scribble
" abre un buffer sin nombre
map <leader>q :e ~/buffer<cr>
" Quickly open a markdown buffer for scribble
" abre un buffer sin nombre, de tipo Markdown
map <leader>x :e ~/buffer.md<cr>
" Toggle paste mode on and off
" activa o desactiva el modo paste
map <leader>pp :setlocal paste!<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
" => sección de definición de funciones
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ejecuta la acción 'str' como dentro de un menú gráfico
function! CmdLine(str)
" crea un menu 'Foo' con un submenú 'Bar' que ejecuta el comando str
exe "menu Foo.Bar :" . a:str
" ejecuta el menú Foo.Bar
emenu Foo.Bar
" borra el menú Foo y todo su contenido
unmenu Foo
endfunction
function! VisualSelection(direction, extra_filter) range
" definición
let l:saved_reg = @"
"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
@ -385,8 +366,7 @@ function! VisualSelection(direction, extra_filter) range
let @" = l:saved_reg
endfunction
" Returns true if paste mode is enabled
" devuelve true si el modo paste está activado
function! HasPaste()
if &paste
return 'PASTE MODE '
@ -394,8 +374,9 @@ function! HasPaste()
return ''
endfunction
" Don't close window, when deleting a buffer
" redefine el comando Bclose
command! Bclose call <SID>BufcloseCloseIt()
" no cierra la ventana cuando se borra un buffer
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
@ -415,6 +396,7 @@ function! <SID>BufcloseCloseIt()
endif
endfunction
" <?>
" Make VIM remember position in file after reopen
" if has("autocmd")
" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif