Giter VIP home page Giter VIP logo

file-line's Introduction

File-line

Plugin for vim to enable opening a file in a given line

When you open a file:line, for instance when coping and pasting from an error from your compiler vim tries to open a file with a colon in its name.

Examples:

vim index.html:20
vim app/models/user.rb:1337

With this little script in your plugins folder if the stuff after the colon is a number and a file exists with the name especified before the colon vim will open this file and take you to the line you wished in the first place.

This script is licensed with GPLv3 and you can contribute to it on github at github.com/bogado/file-line.

Install details

If you use Bundle, add this line to your .vimrc:

Bundle 'bogado/file-line'

And launch :BundleInstall in vim.

Or just copy the file into your plugins path ($HOME/.vim/plugin under unixes).

file-line's People

Contributors

0 avatar bart9h avatar blueyed avatar bogado avatar dorian avatar iirelu avatar inkarkat avatar joe-skb7 avatar jspricke avatar ldong avatar robinro avatar rwstauner avatar xim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

file-line's Issues

Warnings of "autocommand nesting too deep" when opening lots of files

For example:

$ vim a.h:2876 b.h:6051 c.h:6356 c.h:5356 f.cs:3183 g.h:6373 ...

following warning generated:

"a.h:2876" [New File]
Error detected while processing function <SNR>6_gotoline:
line   24:
"b.h:6051" [New File]
E218: autocommand nesting too deep
E218: autocommand nesting too deep
line   26:
E218: autocommand nesting too deep
"c.h" [readonly][dos] 6356L, 374173C
E218: autocommand nesting too deep
"c.h" [readonly][dos] 6356L, 374173C
Error detected while processing function <SNR>5_FTheader:
line   12:
"f.cs" [readonly][dos] 3183L, 195918C
Error detected while processing FileType Auto commands for "*":
"g.h" [readonly][dos] 6373L, 212368C
Press ENTER or type command to continue

Please disable debug messages

Please disable these debug messages:

    echomsg "Found " . a:file_name . " - " . a:line_num . " - " . a:col_num
    echomsg "regexp = " . regexp
    echomsg "file = " . file

:e file:line

I would be really nice if e: filename:linenumber worked as well! Do you guys know how I would be able to get that to work?

Highlighting broken when using set hidden and opening multiple files

Probably closely related to #63

Here is a minimal .vimrc to reproduce :

set nocompatible
syntax enable
set hidden

call plug#begin()
Plug 'ydeweerdt/file-line'
call plug#end()

Then open two existing files, with vim foo.js bar.js run :bn to switch to the next buffer, the syntax highlighting is not applied.

I tried to apply #66 but it doesn't fix it.

Files *ending* in colon

Can you add an option to also strip final colons in a filename?

When you grep files, the filenames with matches have colons at the end and to edit those files I have to delete the colon.

screencast

Since almost no files end in colons optionally stripping them might make sense.

awesome

not really an issue, but just wanted to say file-line is awesome. just what i was looking for :)

Dieter

using a gotoline on the last file breaks -o

These two commands have the same effect:

$ vim README.md plugin/file_line.vim:10 -o

$ vim README.md plugin/file_line.vim:10

And those two also have the same effect:

$ vim README.md:10 plugin/file_line.vim:10 -o

$ vim README.md:10 plugin/file_line.vim:10

This work as expected :

$ vim README.md:10 plugin/file_line.vim -o

and this has no syntax highlight on the second file
$ vim README.md:10 plugin/file_line.vim

Fails on file names with spaces

How to reproduce

touch with\ spaces
vim with\ spaces:0

Result

The following error shows up:

Error detected while processing function <SNR>17_gotoline:
line   25:
E172: Only one file name allowed: keepalt edit with spaces

And the file is not opened.

Expected result

Vim opens the file with spaces and jumps to the given position.

Version

vim: 7.3 Included patches: 1-1070
file-line: 06d6c0e

Sets wrong filetype for jar files

When I use this plugin, it causes Vim to treat jar files as tar files.

:verbose set ft?
filetype=tar
Last set from /usr/share/vim/vim74/autoload/zip.vim

But if I remove this plugin, Vim correctly opens jar files.

Filetype not set on multiple files

The filetype is for some reason not set on the second file if I open multiple files (of the same filetype). The problem only occurs with set hidden. Consider the following minimal working example:

set nocompatible
let &rtp = '~/.vim/bundle/file-line/,' . &rtp
filetype plugin indent on
syntax enable
set hidden
program test1
  implicit none
  !
  print *, "This is test1"
end program test1
program test2
  implicit none
  !
  print *, "This is test2"
end program test2

Now do gvim -u minivimrc *.f90 (or vim) followed by :bnext<cr>. This will go to the next file, which does not have any syntax highlighting because the filetype is not set.

This issue is similar to #28 and #29, which were closed as fixed in #34. However, the above procedure clearly shows that the current issue exists and is reproducible.

Edit: Minor update.

Opening a file read-only, that is already opened, breaks

When opening a file, that is already opened with another instance of (neo-)vim, you usually see this error message:

E325: ATTENTION
Found a swap file by the name ...

Then you have the choices:

[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: 

When you choose [O]pen Read-Only or (R)ecover, you see this error message:

Error detected while processing function <SNR>71_startup:
line    7:

...which seems to belong to the exec call in s:startup function:

function! s:startup()
autocmd BufNewFile * nested call s:gotoline()
autocmd BufRead * nested call s:gotoline()
if argc() > 0
let argidx=argidx()
silent call s:handle_arg()
exec (argidx+1).'argument'
" Manually call Syntax autocommands, ignored by `:argdo`.
doautocmd Syntax
doautocmd FileType
endif
endfunction

I have no glue, what the function does, but (argidx+1).'argument' seems to be 1argument at this point.

:bwipe breaks vim -p

I am used to executing vim -p to open all files in tabs.

If the first file is given a line number, vim -p does not open the files in tabs.

I tried removing the :bwipe, and that gives me the expected behaviour (sans the outout of :ls)

new bufdo startup sequence break fugitive.

In my configuration the new startup sequence is somehow unloading fugitive if the reopenAndGotoFile is invoked.

reproduce steps :

$ cd <path_to_file_line>
$ vim plugin/file_line.vim:

check that :Gblame is not defined.

Jump to file_name:line_number from stack trace

Is it possible to jump to a file:line_number if it was writer inside vim itself. Like for example, from a stack trace in the vim terminal, or if I write PageBase:75 inside a document, the gf or gF command moves me to the desired line number in the file?

I tried using this: https://github.com/wsdjeg/vim-fetch but it isn't working for me (The plugin is crashing)

`:sp file:line` closes existing splits

Thank you for the plugin! I am loving it, it is very useful for pasting error messages from the console.

I have run into one issue. Finally got around to reducing it to a simple case...

Replication:

  • MacVim (version: VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 20 2014 10:38:46))
  • given local files one.txt and two.txt with a few lines in each
  • $ mvim one.txt
  • :sp two.txt:2

Behavior:

  • removes one.txt from view and puts two.txt in its place

Expected behavior:

  • open two.txt in a new split and keep one.txt open

Notes:

  • in the error case above :buffers shows both files, so I think it is not closing the buffer but removing it from view (I don't have a fantastic understanding of the relation of buffer and view, or I could elaborate more. :| )
  • if I have one.txt and two.txt open, and try :sp two.txt:3, it correctly opens the split at the right place and does not close the others (three viewports open total)

Support for :e command

Awesome, I wanted this for long. Is it possible to also support that for the :e command ? Just give me some pointers and I'll send you a pull request

"." is a directory

When I open vim via vim .

I get the following.

"." is a directory
"." is a directory
Press ENTER or type command to continue

Any ideas?

How to support "file:line:garbage"?

When I grep for some source, I might get output like this:

arch/arm/include/asm/fiq.h:37:extern void release_fiq(struct fiq_handler *f);
arch/arm/include/asm/fiq.h:38:extern void set_fiq_handler(void *start, unsigned int length);
arch/arm/include/asm/fiq.h:39:extern void enable_fiq(int fiq);

Double clicking will give me the extra "extern" (or some other text) after the : where file_line expects a column number.

I've tried to decypher the matchlist expression, but I cannot work out how to make it pass when "garbage" is passed instead of a column number.

Also keep in mind, at least in C, some of the lines might also have things like # in them:

arch/arm/include/asm/tlbflush.h:13:#ifdef CONFIG_MMU

Is it possible to parse this and discard the garbage?

Breaks syntax highlighting for all but first file when opening multiple files at once.

When opening multiple files at once like vim file1.py file2.py, only file1.py will have syntax highlighting enabled. For file2.py, no :set syntax is available and I have to set it manually.

I install files with Vundle, so here's my Plugin list, maybe this helps:

 Plugin 'flazz/vim-colorschemes'
 Plugin 'scrooloose/syntastic'
 Plugin 'Valloric/YouCompleteMe'
 Plugin 'evanmiller/nginx-vim-syntax'
 Plugin 'othree/html5.vim'
 Plugin 'othree/javascript-libraries-syntax.vim'
 Plugin 'pangloss/vim-javascript'
 Plugin 'rdolgushin/gitignore.vim'
 Plugin 'gregsexton/MatchTag'
 Plugin 'justinmk/vim-syntax-extra'
 Plugin 'nathanaelkane/vim-indent-guides'
 Plugin 'bogado/file-line'

Blank file buffer named "scheme" opened when using netrw "scheme://host//file" syntax

With a recent version of netrw installed, this plugin causes multiple buffers to be opened when using a command e.g.
vim scp://some.validhost.com//path/to/file.txt

which opens a blank buffer with name "scp" as the first buffer, and the expected netrw buffer editing "/path/to/file.txt" on remote host some.validhost.com as the second buffer.

I assume any version combination of netrw/file-line manifests this issue, but for reference I am using version v153 of netrw, and SHA a1381d0 for file-line.

Breaks shell redirection and pipes

The file-line plugin breaks shell redirection: the command below should start vim with a buffer containing its manpage, but instead vim shows an empty buffer with a name like "/proc/65432/fd/63".

vim <(man vim)

The plugin breaks it because it tries to re-read the buffer, which is not possible from a pipe. You can fix the example above like this, though it would be better to do a more general check for pipes (and other special files) because they can also only be read once.

90c90
< if match(expand("%:p"), "^/proc/.*/fd/.*$") < 0 && match(expand("%:p"), "^/dev/fd/.*$") < 0 && !isdirectory(expand("%:p"))
---
> if !isdirectory(expand("%:p"))

file-line doesn't work when first character in file is tab

If file contains tab character in the beginning, followed by some other character, like:

[tab]ABC

then file-line doesn't work, i.e. if you are trying to do:

$ vim Documentation/crypto/async-tx-api.txt:203

it doesn't work.

The example of such file is here.

-p broken

When using the following command:

% vim -p foo:10 bar:20

Only foo is opened.

Break gzip plugins

gz files are not decompressed.
when a gz file is opened from vim decompression is done.

vim toto.gz won't work
vim then :e toto.gz will

version 1.0 is ok cfc14a4
master KO

git bisect give bcada53 as the first bad commit

-o/-O broken

if you try to open 2 or more files with line numbers the window wont be split. eg

vim -O file1.txt file2.txt:33

this opens both files but no split and only file1.txt is visible. Note that switching to file2.txt the cursor is on the correct line. Also if not line numbers are specified everything works OK.

Opening same file with different line numbers

$ vi a.txt:10 a.txt:36

I'm expecting it to open two "files", I can then use :n and :prev to navigate between them.

With old version it is working exactly as I expected, but in new version, the cursor only stays at the last position.

Breaks swapchoice setting?

Not sure why this is happening, but I'm pretty sure this plugin breaks the v:swapchoice varaible.

I have a section of code in my vimrc like:

augroup NoSimultaneousEdits
  autocmd!
  autocmd SwapExists * let v:swapchoice = 'o'
augroup END

Here's some online explanation.

It looks like vim (and nvim) no longer respect the swapchoice setting when this plugin is loaded. It works for 'q' and 'a' (I didn't try others), but not 'o' (probably the most common choice). Any idea what's going on here?

Breaks templates loading

I have next line in my .vimrc:

au BufNewFile main.c silent! 0r ~/.vim/skeleton/template.%:e

This loads content from template file when I'm creating new main.c file.
But when file-line plugin is installed -- this functionality doesn't work (newly created main.c is blank).

Breaks highlight by other plugins

vim-linux-coding-style plugin automatically highlights data types like u8, __u8 etc. But file-line plugin breaks that highlighting.

Next workaround fixes it for me:

@@ -79,10 +79,6 @@ function! s:startup()

    if argc() > 0
        let argidx=argidx()
-       silent argdo call s:handle_arg()
-       exec (argidx+1).'argument'
-       " Manually call Syntax autocommands, ignored by `:argdo`.
-       doautocmd Syntax
    endif
 endfunction

But more elegant solution should be found, I guess (because I believe that the code I removed was added for a reason).

Breaks vim gnupg plugin

I’m filing this issue both here and for jamessan/vim-gnupg.

When both plugins are active the gnupg plugin stops working and displays a scrambled buffer for encrypted .gpg files.

In my list of bundles I bisected all plugins until I determined that when file-line is disabled, the gnupg decoding works again.

breaks NERDTree plugin

Commit 'bcada' breaks NERDTree in the following case:
when run Vim with a directory as an argument, such as
vim some_dir
NERDTree doesn't became active as it should (NERDTreeHijackNetrw is on).

Also I found next bug:
With vim-startify plugin and no NERDTree, neither Netrw nor file:line don't work. Probably this one is connected to startify, but the strange thing is that with both plugins: startify and NERDTree, and the commit reverted everything works.

nvim foo.cc:42 opens in buffer 2

I'm using NVIM v0.4.3 with this plugin. I noticed that when opening a file to a line number it opens in buffer 2 rather than buffer 1. For example:

nvim foo.txt  # Opens in buffer 1, run :ls to see
nvim foo.txt:1 # Opens in buffer 2, run :ls to see

This isn't really a problem, but it's strange so I'm reporting it. Is there any way to fix this?

Support for gf command

First of all thank you for your work!

It'd be great to invoke the plugin for "gf" action as "e" does (#1). It'd be more than useful for coredump analise for example.

Thank you!

About host:/file

I’ve been wondering how I can get around the awkward netrw URL notation:

vim scp://host.domain.com//home/user/.bashrc

Do you think, when you encounter a colon and it’s not followed by a number, or it’s the final character, you could check if it looks like an SSH host:file notation and then rewrite it into the above notation

vim host.domain.com:/home/user/.bashrc
or
vim host.lan:.bashrc

I could imagine checking .ssh/config for Host entries could work. Perhaps there’s an existing unrelated plugin, but I can’t find anything.

Breaks templates loading

The same issue ( #61 ) was closed by mistake, so creating new one (duplicate).

I have next line in my .vimrc:

au BufNewFile main.c silent! 0r ~/.vim/skeleton/template.c

This loads content from template file when I'm creating new main.c file.
But when file-line plugin is installed -- this functionality doesn't work (newly created main.c is blank).

More detailed description is here: #60 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.